summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-03-07 19:15:53 +0100
committerDylan William Hardison <dylan@hardison.net>2017-03-07 23:52:13 +0100
commitd1cf67fc2271981260e919795706ee051a3279c9 (patch)
tree1d2f336d9cc22c7cf132e4fd45304b3f235bcf62 /Bugzilla/Util.pm
parent9c26c01867ca3e2af1e70c051140eea59c68c500 (diff)
downloadbugzilla-d1cf67fc2271981260e919795706ee051a3279c9.tar.gz
bugzilla-d1cf67fc2271981260e919795706ee051a3279c9.tar.xz
Bug 1345181 - Improve performance of html_quote()
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r--Bugzilla/Util.pm15
1 files changed, 9 insertions, 6 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index fd0f8b92e..4371441a0 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -65,17 +65,20 @@ sub detaint_signed {
return (defined($_[0]));
}
+my %html_quote = (
+ q{&} => '&amp;',
+ q{<} => '&lt;',
+ q{>} => '&gt;',
+ q{"} => '&quot;',
+ q{@} => '&#64;', # Obscure '@'.
+);
+
# Bug 120030: Override html filter to obscure the '@' in user
# visible strings.
# Bug 319331: Handle BiDi disruptions.
sub html_quote {
my $var = shift;
- $var =~ s/&/&amp;/g;
- $var =~ s/</&lt;/g;
- $var =~ s/>/&gt;/g;
- $var =~ s/"/&quot;/g;
- # Obscure '@'.
- $var =~ s/\@/\&#64;/g;
+ $var =~ s/([&<>"@])/$html_quote{$1}/g;
state $use_utf8 = Bugzilla->params->{'utf8'};