From 3b4065719921c2dc6f620aa5aa17d33c7d6d1c95 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Thu, 11 Oct 2012 18:41:57 -0400 Subject: Bug 799257 - Backport bug 795650 and bug 797833 to bmo/4.0 and bmo/4.2 for performance improvement r=glob --- Bugzilla/Util.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'Bugzilla/Util.pm') diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index c2dbdc97d..c754f4081 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -119,6 +119,9 @@ sub html_quote { sub html_light_quote { my ($text) = @_; + # admin/table.html.tmpl calls |FILTER html_light| many times. + # There is no need to recreate the HTML::Scrubber object again and again. + my $scrubber = Bugzilla->process_cache->{html_scrubber}; # List of allowed HTML elements having no attributes. my @allow = qw(b strong em i u p br abbr acronym ins del cite code var @@ -140,7 +143,7 @@ sub html_light_quote { $text =~ s#$chr($safe)$chr#<$1>#go; return $text; } - else { + elsif (!$scrubber) { # We can be less restrictive. We can accept elements with attributes. push(@allow, qw(a blockquote q span)); @@ -183,14 +186,14 @@ sub html_light_quote { }, ); - my $scrubber = HTML::Scrubber->new(default => \@default, - allow => \@allow, - rules => \@rules, - comment => 0, - process => 0); - - return $scrubber->scrub($text); + Bugzilla->process_cache->{html_scrubber} = $scrubber = + HTML::Scrubber->new(default => \@default, + allow => \@allow, + rules => \@rules, + comment => 0, + process => 0); } + return $scrubber->scrub($text); } sub email_filter { -- cgit v1.2.3-24-g4f1b