Commit aeeddc17 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 795650: Cache the HTML::Scrubber object for improved performance

r=glob a=LpSolit
parent 75b15ff3
...@@ -95,6 +95,9 @@ sub html_quote { ...@@ -95,6 +95,9 @@ sub html_quote {
sub html_light_quote { sub html_light_quote {
my ($text) = @_; 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. # 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 my @allow = qw(b strong em i u p br abbr acronym ins del cite code var
...@@ -116,7 +119,7 @@ sub html_light_quote { ...@@ -116,7 +119,7 @@ sub html_light_quote {
$text =~ s#$chr($safe)$chr#<$1>#go; $text =~ s#$chr($safe)$chr#<$1>#go;
return $text; return $text;
} }
else { elsif (!$scrubber) {
# We can be less restrictive. We can accept elements with attributes. # We can be less restrictive. We can accept elements with attributes.
push(@allow, qw(a blockquote q span)); push(@allow, qw(a blockquote q span));
...@@ -160,14 +163,14 @@ sub html_light_quote { ...@@ -160,14 +163,14 @@ sub html_light_quote {
}, },
); );
my $scrubber = HTML::Scrubber->new(default => \@default, Bugzilla->process_cache->{html_scrubber} = $scrubber =
HTML::Scrubber->new(default => \@default,
allow => \@allow, allow => \@allow,
rules => \@rules, rules => \@rules,
comment => 0, comment => 0,
process => 0); process => 0);
return $scrubber->scrub($text);
} }
return $scrubber->scrub($text);
} }
sub email_filter { sub email_filter {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment