From 6c7a939f44dac0101526359b333ac75b85d9ad91 Mon Sep 17 00:00:00 2001 From: Shawn Iverson Date: Thu, 29 Nov 2018 12:47:25 -0500 Subject: [PATCH] Cleanup email text (#321) Fix Issue #320 Move split operation to after text cleanup --- common/usr/share/MailScanner/perl/MailScanner/Message.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/usr/share/MailScanner/perl/MailScanner/Message.pm b/common/usr/share/MailScanner/perl/MailScanner/Message.pm index 2d427f7..2d7d5b8 100644 --- a/common/usr/share/MailScanner/perl/MailScanner/Message.pm +++ b/common/usr/share/MailScanner/perl/MailScanner/Message.pm @@ -7571,11 +7571,14 @@ sub DisarmEndtagCallback { $squashedtext =~ tr/\n/ /; # Join multiple lines onto 1 line $squashedtext =~ s/(\<\/?[a-z][a-z0-9:._-]*((\s+[a-z][a-z0-9:._-]*(\s*=\s*(?:\".*?\"|\'.*?\'|[^\'\">\s]+))?)+\s*|\s*)\/?\>)*//ig; # Remove tags, better re from snifer_@hotmail.com $squashedtext =~ s/\s+//g; # Remove any whitespace - if ( $squashedtext =~ /@/ ) { - my @list = split(/@/, $squashedtext); + if ( $DisarmLinkURL =~ m/^ma[il]+to[:;]/i && $squashedtext =~ /@/ ) { # Remove any leading or trailing text $squashedtext =~ s/^.*\s+(?=.*\@)//; $squashedtext =~ s/\s+.*$//; + # Remove > and < tags, if present + # https://github.com/MailScanner/v5/issues/320 + $squashedtext =~ s/(?:<|>)//g; + my @list = split(/@/, $squashedtext); $emailuser = $list[0]; $squashedtext = $list[1]; # Remove username of email addresses }