]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1345181 - Improve performance of html_quote()
authorDylan William Hardison <dylan@hardison.net>
Tue, 7 Mar 2017 18:15:53 +0000 (13:15 -0500)
committerDylan William Hardison <dylan@hardison.net>
Tue, 7 Mar 2017 22:52:13 +0000 (17:52 -0500)
Bugzilla/Util.pm

index fd0f8b92e4b6e182e51ca4a8e6b3391726cc0408..4371441a043cb155a31f2a01ef578b5ae7b862a3 100644 (file)
@@ -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'};