You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@spamassassin.apache.org on 2019/08/12 09:23:31 UTC
[Bug 6583] log_message and get_content_preview should print safe
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=6583
--- Comment #11 from Henrik Krohns <ap...@hege.li> ---
Committed to trunk in backwards and 3rd party compatible way.
New escape => 1 option is used everywhere in SA code, for example:
Mail::SpamAssassin::Logger::add(method => 'stderr',
timestamp_fmt => $log_timestamp_fmt,
escape => 1);
If escape is not defined at all (like current Amavis), normal pre-4.0 method is
used.
This is the used method, which is moved into all Logger/*.pm modules.
if ($self->{escape}) {
local $1;
# Bug 7305:
# Quote non-ascii characters as \x{XX} or \x{XXXX} (Unicode)
# Also quote backslash, so the log can be unescaped properly
$msg =~ s{([^\x20-\x5b\x5d-\x7e])}{ $1 eq '\\' ? '\\\\' :
sprintf(ord($1) > 255 ? '\\x{%04X}' : '\\x{%02X}', ord($1)) }egs;
} elsif (!exists $self->{escape}) {
# Backwards compatible pre-4.0 escaping, if $escape not given.
# replace control characters with "_", tabs and spaces get
# replaced with a single space.
$msg =~ tr/\x09\x20\x00-\x1f/ _/s;
}
I hate octal presensation, so it's \x{FF} and \x{FFFF} to be uniform.
Should have done this long time ago, it's super helpful!
Aug 12 12:20:25.854 [11986] dbg: rules: ran rawbody rule __L_BODY_8BITS ======>
got hit: "\x{EF}"
Aug 12 12:20:48.846 [12007] dbg: rules: ran rawbody rule __HAS_HREF ======> got
hit: "\x{09}\x{09}<td><a href="
Aug 12 12:21:54.700 [12081] dbg: message: _decode_header subject: Fyll inn alle
detaljene for \x{C3}\x{B8}nsket l\x{C3}\x{A5}n
Aug 12 12:21:54.902 [12081] dbg: rules: ran body rule __HIGHBITS ======> got
hit: "\x{C3}\x{83}\x{C2}\x{B8}n"
Aug 12 12:22:56.663 [12272] dbg: uri: canonicalizing parsed uri:
http://www\x{E3}\x{80}\x{82}example3\x{E3}\x{80}\x{82}com
Sending trunk/UPGRADE
Sending trunk/lib/Mail/SpamAssassin/Logger/File.pm
Sending trunk/lib/Mail/SpamAssassin/Logger/Stderr.pm
Sending trunk/lib/Mail/SpamAssassin/Logger/Syslog.pm
Sending trunk/lib/Mail/SpamAssassin/Logger.pm
Sending trunk/spamd/spamd.raw
Transmitting file data ......done
Committing transaction...
Committed revision 1864949.
--
You are receiving this mail because:
You are the assignee for the bug.