Mailing List Archive

svn commit: rev 9830 - incubator/spamassassin/trunk/lib/Mail/SpamAssassin
Author: felicity
Date: Tue Mar 30 15:53:21 2004
New Revision: 9830

Modified:
incubator/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Log:
bug 3227: 'To: display-name: foo@bar ;' wasn't being properly handled (see RFC2822 for 'group'). I modified the code to trim out the address/name in the group situation, as well as cleaning off the excess whitespace in the address/name situations.

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Tue Mar 30 15:53:21 2004
@@ -1100,17 +1100,42 @@
}

if (defined) {
- if ($getaddr) {
- s/\r?\n//gs;
- s/\s*\(.*?\)//g; # strip out the (comments)
- s/^[^<]*?<(.*?)>.*$/$1/; # "Foo Blah" <jm@foo> or <jm@foo>
- s/, .*$//gs; # multiple addrs on one line: return 1st
- s/ ;$//gs; # 'undisclosed-recipients: ;'
- }
- elsif ($getname) {
- chomp; s/\r?\n//gs;
- s/^[\'\"]*(.*?)[\'\"]*\s*<.+>\s*$/$1/g # Foo Blah <jm@foo>
- or s/^.+\s\((.*?)\)\s*$/$1/g; # jm@foo (Foo Blah)
+ if ($getaddr || $getname) {
+ s/^[^:]+:(.*);\s*$/$1/gs; # 'undisclosed-recipients: ;'
+ s/\s+/ /g; # reduce whitespace to single space
+ s/^\s+//; # leading wsp
+ s/\s+$//; # trailing wsp
+ s/,.*$//; # multiple addrs on one line? remove all but first
+
+ if ($getaddr) {
+ # Get the email address out of the header
+ # All of these should result in "jm@foo":
+ #
+ # jm@foo
+ # jm@foo (Foo Blah)
+ # jm@foo, jm@bar
+ # display: jm@foo (Foo Blah), jm@bar ;
+ # Foo Blah <jm@foo>
+ # "Foo Blah" <jm@foo>
+ # "'Foo Blah'" <jm@foo>
+ #
+ s/\s*\(.*?\)//g; # strip out the (comments)
+ s/^[^<]*?<(.*?)>.*$/$1/; # "Foo Blah" <jm@foo> or <jm@foo>
+ }
+ elsif ($getname) {
+ # Get the real name out of the header
+ # All of these should result in "Foo Blah":
+ #
+ # jm@foo (Foo Blah)
+ # jm@foo (Foo Blah), jm@bar
+ # display: jm@foo (Foo Blah), jm@bar ;
+ # Foo Blah <jm@foo>
+ # "Foo Blah" <jm@foo>
+ # "'Foo Blah'" <jm@foo>
+ #
+ s/^[\'\"]*(.*?)[\'\"]*\s*<.+>\s*$/$1/g
+ or s/^.+\s\((.*?)\)\s*$/$1/g; # jm@foo (Foo Blah)
+ }
}
}
$self->{hdr_cache}->{$request} = $_;