From: Sven Schöling Date: Wed, 27 Dec 2017 10:08:52 +0000 (+0100) Subject: Presenter::EscapedText: quote_html nicht über $::locale laufen lassen X-Git-Tag: release-3.5.4~547 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=be5cae093b3218e8a1dcaa31911a43781ea3261f;p=kivitendo-erp.git Presenter::EscapedText: quote_html nicht über $::locale laufen lassen Die quote_html Liste in speacial_chars ist extrem langsam. Für HTML Generierung lieber diese optimierte nehmen. --- diff --git a/SL/Presenter/EscapedText.pm b/SL/Presenter/EscapedText.pm index 2fc04fdeb..ca3c8ca62 100644 --- a/SL/Presenter/EscapedText.pm +++ b/SL/Presenter/EscapedText.pm @@ -10,6 +10,14 @@ use JSON (); use overload '""' => \&escaped_text; +my %html_entities = ( + '<' => '<', + '>' => '>', + '&' => '&', + '"' => '"', + "'" => ''', +); + # static constructors sub new { my ($class, %params) = @_; @@ -17,11 +25,17 @@ sub new { return $params{text} if ref($params{text}) eq $class; my $self = bless {}, $class; - $self->{text} = $params{is_escaped} ? $params{text} : $::locale->quote_special_chars('HTML', $params{text}); + $self->{text} = $params{is_escaped} ? $params{text} : quote_html($params{text}); return $self; } +sub quote_html { + return undef unless defined $_[0]; + (my $x = $_[0]) =~ s/(["'<>&])/$html_entities{$1}/ge; + $x +} + sub escape { __PACKAGE__->new(text => $_[0]); }