From: Dylan William Hardison Date: Tue, 7 Mar 2017 18:15:53 +0000 (-0500) Subject: Bug 1345181 - Improve performance of html_quote() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1cf67fc2271981260e919795706ee051a3279c9;p=thirdparty%2Fbugzilla.git Bug 1345181 - Improve performance of html_quote() --- 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{&} => '&', + q{<} => '<', + q{>} => '>', + q{"} => '"', + q{@} => '@', # 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/&/&/g; - $var =~ s//>/g; - $var =~ s/"/"/g; - # Obscure '@'. - $var =~ s/\@/\@/g; + $var =~ s/([&<>"@])/$html_quote{$1}/g; state $use_utf8 = Bugzilla->params->{'utf8'};