Subject: | Truncate an HTML entity also truncate the entity |
Date: | Mon, 4 May 2015 13:31:15 -0500 |
To: | bug-HTML-Truncate [...] rt.cpan.org |
From: | Carlos Rodríguez <carlos.rodriguez [...] otrs.com> |
If you set to truncate to a certain amount of characters and there is an entity in the truncating point it is also truncated e.g. "ó" could be truncated to "&oacu…”, here is how I workaround the issue:
@@ -383,7 +383,11 @@ sub truncate {
{
next TOKEN if $token->[2]; # DATA
# my $txt = HTML::Entities::decode($token->[1]);
- my $txt = $token->[1];
+# ---
+# Patched by OTRS
+ # my $txt = $token->[1];
+ my $txt = HTML::Entities::decode($token->[1]);
+# ---
my $current_length = 0;
unless ( first { $_ eq 'pre' } @tag_q ) # We're not somewhere inside a <pre/>
{
@@ -427,6 +431,11 @@ sub truncate {
else
{
$keep = substr($txt, 0, $chars_to_keep);
+# ---
+# Patched by OTRS
+
+ $keep = $self->utf8_mode ? $keep : HTML::Entities::encode($keep);
+# ---
}
if ( my $cleaner = $self->cleanly )
((enjoy))
Carlos Rodríguez
Message body not shown because it is not plain text.