@@ -924,6 +924,10 @@ sub quote_subject {# use the simplest quoting being able to handle the recipientsubsanitize_address{my($recipient)=@_;++# remove garbage after email address+$recipient=~s/(.*>).*$/$1/;+
Looks fine, but I would do s/(.*?>)(.*)$/$1/, so that 'test
[off-list ref] <#comment>' gets the second comment removed.
Yeah, but do you need to capture the second group? IOW, like
"s/(.*?>).*$/$1/" perhaps?
@@ -924,6 +924,10 @@ sub quote_subject {# use the simplest quoting being able to handle the recipientsubsanitize_address{my($recipient)=@_;++# remove garbage after email address+$recipient=~s/(.*>).*$/$1/;+
Looks fine, but I would do s/(.*?>)(.*)$/$1/, so that 'test
[off-list ref] <#comment>' gets the second comment removed.
Yeah, but do you need to capture the second group? IOW, like
"s/(.*?>).*$/$1/" perhaps?
I also thought about removing everything after first ">", but I will
not work for addresses like:
Cc: "foo >" <redacted> #v3.4 v3.5 v3.6
What about:
$recipient =~ s/(.*<[^@]*@[^]]*>).*$/$1/;
or even
@@ -924,6 +924,10 @@ sub quote_subject {# use the simplest quoting being able to handle the recipientsubsanitize_address{my($recipient)=@_;++# remove garbage after email address+$recipient=~s/(.*>).*$/$1/;+
Looks fine, but I would do s/(.*?>)(.*)$/$1/, so that 'test
[off-list ref] <#comment>' gets the second comment removed.
Yeah, but do you need to capture the second group? IOW, like
"s/(.*?>).*$/$1/" perhaps?
I also thought about removing everything after first ">", but I will
not work for addresses like:
Cc: "foo >" <redacted> #v3.4 v3.5 v3.6
What about:
$recipient =~ s/(.*<[^@]*@[^]]*>).*$/$1/;
or even
which uses regex used by 99% accurate version of extract_valid_address().
Of course, as you suggested earier, only the first email address should
be used, so in both cases the first ".*" should be changed to ".*?".
The second version becomes:
@@ -925,8 +925,11 @@ sub quote_subject {subsanitize_address{my($recipient)=@_;+my$local_part_regexp=qr/[^<>"\s@]+/;+my$domain_regexp=qr/[^.<>"\s@]+(?:\.[^.<>"\s@]+)+/;+# remove garbage after email address-$recipient=~s/(.*>).*$/$1/;+$recipient=~s/^(.*?<$local_part_regexp\@$domain_regexp>).*/$1/;
I don't think all that extra complexity is warranted, to me
s/(.*?>)(.*)$/$1/ is just fine.
It's intentionally left without the at-sign so one can send mail to a
local account as well as remote ones. Very nifty when debugging, and
when one wants to preview outgoing emails.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
@@ -925,8 +925,11 @@ sub quote_subject {subsanitize_address{my($recipient)=@_;+my$local_part_regexp=qr/[^<>"\s@]+/;+my$domain_regexp=qr/[^.<>"\s@]+(?:\.[^.<>"\s@]+)+/;+# remove garbage after email address-$recipient=~s/(.*>).*$/$1/;+$recipient=~s/^(.*?<$local_part_regexp\@$domain_regexp>).*/$1/;
I don't think all that extra complexity is warranted, to me
s/(.*?>)(.*)$/$1/ is just fine.
Yeah, it's a little bit too complex, but "s/(.*?>)(.*)$/$1/"
causes small regression - '>' character is no longer allowed
in "phrase" before "<email address>". Maybe the initial version,
that removes everything after last '>' is better? In this case '>'
is not allowed in garbage after email.
Krzysiek