aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-12-14 16:57:15 +0000
committerStruan Donald <struan@exo.org.uk>2019-01-04 10:35:49 +0000
commitcd4c9634b73eea847a1436f201e44de9c7e04d69 (patch)
treed76e3142afbcf7aa5bcb9d75c6cf6cca3aa56f63 /perllib/FixMyStreet
parent8ce5719937b7c589a4c5f65ed5b2ceb9637b9fcf (diff)
[Buckinghamshire] add report description filtering
Add a method to do some basic filtering of emails and phone numbers from report descriptions. To be used on reports pulled in from Confirm as a first pass at removing personal information.
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/Cobrand/Buckinghamshire.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
index 055e481d9..c8432c4d7 100644
--- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
@@ -109,6 +109,23 @@ sub open311_config_updates {
$params->{mark_reopen} = 1;
}
+sub filter_report_description {
+ my ($self, $description) = @_;
+
+ # this allows _ in the domain name but I figure it's unlikely to
+ # generate false positives so lets go with that for the same of
+ # a simpler regex
+ $description =~ s/\b[\w.!#$%&'*+\-\/=?^_{|}~]+\@[\w\-]+\.[^ ]+\b//g;
+ $description =~ s/ (?: \+ \d{2} \s? | \b 0 ) (?:
+ \d{2} \s? \d{4} \s? \d{4} # 0xx( )xxxx( )xxxx
+ | \d{3} \s \d{3} \s? \d{4} # 0xxx xxx( )xxxx
+ | \d{3} \s? \d{2} \s \d{4,5} # 0xxx( )xx xxxx(x)
+ | \d{4} \s \d{5,6} # 0xxxx xxxxx(x)
+ ) \b //gx;
+
+ return $description;
+}
+
sub map_type { 'Buckinghamshire' }
sub default_map_zoom { 3 }