summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2012-10-08 17:02:32 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2012-10-08 17:02:32 +0200
commit50a6d3b41fc549c36c271784ac7a842230cb8408 (patch)
treebe1a3da65d5e8b9b74d5b27768f496e8b8a3254d /Bugzilla/Util.pm
parenta6ff444d9a4d6a40623a9899731d9b3467984b7d (diff)
downloadbugzilla-50a6d3b41fc549c36c271784ac7a842230cb8408.tar.gz
bugzilla-50a6d3b41fc549c36c271784ac7a842230cb8408.tar.xz
Bug 795650: Cache the HTML::Scrubber object for improved performance
r=glob a=LpSolit
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r--Bugzilla/Util.pm19
1 files changed, 11 insertions, 8 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 9e1a01e2d..125b2445f 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -96,6 +96,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
@@ -117,7 +120,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));
@@ -161,14 +164,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 {