summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Template.pm12
-rw-r--r--Bugzilla/Util.pm4
2 files changed, 16 insertions, 0 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 56d31dd2d..6f7900054 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -678,6 +678,18 @@ sub create {
my ($data) = @_;
return encode_base64($data);
},
+
+ # Strips out control characters excepting whitespace
+ strip_control_chars => sub {
+ my ($data) = @_;
+ state $use_utf8 = Bugzilla->params->{'utf8'};
+ # Only run for utf8 to avoid issues with other multibyte encodings
+ # that may be reassigning meaning to ascii characters.
+ if ($use_utf8) {
+ $data =~ s/(?![\t\r\n])[[:cntrl:]]//g;
+ }
+ return $data;
+ },
# HTML collapses newlines in element attributes to a single space,
# so form elements which may have whitespace (ie comments) need
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 5f359c38c..9bcb6962d 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -75,6 +75,10 @@ sub html_quote {
state $use_utf8 = Bugzilla->params->{'utf8'};
if ($use_utf8) {
+ # Remove control characters if the encoding is utf8.
+ # Other multibyte encodings may be using this range; so ignore if not utf8.
+ $var =~ s/(?![\t\r\n])[[:cntrl:]]//g;
+
# Remove the following characters because they're
# influencing BiDi:
# --------------------------------------------------------