You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2019/08/12 11:48:36 UTC
svn commit: r1864961 -
/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Author: hege
Date: Mon Aug 12 11:48:36 2019
New Revision: 1864961
URL: http://svn.apache.org/viewvc?rev=1864961&view=rev
Log:
Escape Content preview: output
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1864961&r1=1864960&r2=1864961&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Mon Aug 12 11:48:36 2019
@@ -925,14 +925,13 @@ sub get_content_preview {
my ($self) = @_;
my $str = '';
- my $ary = $self->get_decoded_stripped_body_text_array();
- shift @{$ary}; # drop the subject line
+ my @ary = @{$self->get_decoded_stripped_body_text_array()};
+ shift @ary; # drop the subject line
my $numlines = 3;
- while (length ($str) < 200 && @{$ary} && $numlines-- > 0) {
- $str .= shift @{$ary};
+ while (length ($str) < 200 && @ary && $numlines-- > 0) {
+ $str .= shift @ary;
}
- undef $ary;
# in case the last line was huge, trim it back to around 200 chars
local $1;
@@ -945,6 +944,10 @@ sub get_content_preview {
$str =~ s/[-_*.]{10,}//gs;
$str =~ s/\s+/ /gs;
+ # escape non-ascii stuff like Logger does
+ $str =~ s{([^\n\x20-\x5b\x5d-\x7e])}{ $1 eq '\\' ? '\\\\' :
+ sprintf(ord($1) > 255 ? '\\x{%04X}' : '\\x{%02X}', ord($1)) }egs;
+
# add "Content preview:" ourselves, so that the text aligns
# correctly with the template -- then trim it off. We don't
# have to get this *exactly* right, but it's nicer if we