Die quote_html Liste in speacial_chars ist extrem langsam. Für HTML
Generierung lieber diese optimierte nehmen.
use overload '""' => \&escaped_text;
+my %html_entities = (
+ '<' => '<',
+ '>' => '>',
+ '&' => '&',
+ '"' => '"',
+ "'" => ''',
+);
+
# static constructors
sub new {
my ($class, %params) = @_;
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]);
}