X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FHTML%2FUtil.pm;h=c62fd9202e1c32927ebd32c5dc96e34aaca5161c;hb=833f083eae2a4547c49f8f92a2fdca6ba4dfe5f4;hp=7212d646ffef763f22744972b07bf45b9c66c717;hpb=792ae733e8f54eca6d306ad523a7a6e166fcb0e0;p=kivitendo-erp.git diff --git a/SL/HTML/Util.pm b/SL/HTML/Util.pm index 7212d646f..c62fd9202 100644 --- a/SL/HTML/Util.pm +++ b/SL/HTML/Util.pm @@ -6,12 +6,22 @@ use warnings; use HTML::Parser; my %stripper; +my %entities = ( + 'lt' => '<', + 'gt' => '>', + 'amp' => '&', +); sub strip { my ($class_or_value) = @_; my $value = !ref($class_or_value) && (($class_or_value // '') eq 'SL::HTML::Util') ? $_[1] : $class_or_value; + return '' unless defined $value; + + # Remove HTML comments. + $value =~ s{ }{}gx; + if (!%stripper) { %stripper = ( parser => HTML::Parser->new ); @@ -22,6 +32,8 @@ sub strip { $stripper{parser}->parse($value); $stripper{parser}->eof; + $stripper{text} =~ s{\&([^;]+);}{ $entities{$1} || "\&$1;" }eg; + return delete $stripper{text}; }