Skip Menu |
 

This queue is for tickets about the MailTools CPAN distribution.

Report information
The Basics
Id: 16037
Status: resolved
Priority: 0/
Queue: MailTools

People
Owner: Nobody in particular
Requestors: jgmyers [...] proofpoint.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.67
Fixed in: (no value)

Attachments


Subject: Optimize some regexes
Download (untitled) / with headers
text/plain 161b
The attached patch optimizes some regexes in Mail::Address. Without the * after the [], Perl's C stack overflowed when parsing an extremely long quoted-string.
diff -ur MailTools-1.67/blib/lib/Mail/Address.pm MailTools-1.67-fix/blib/lib/Mail/Address.pm --- MailTools-1.67/blib/lib/Mail/Address.pm 2005-01-20 01:17:54.000000000 -0800 +++ MailTools-1.67-fix/blib/lib/Mail/Address.pm 2005-11-22 11:26:25.000000000 -0800 @@ -119,8 +119,8 @@ next; } - s/^("([^"\\]|\\.)*")\s*// # "..." - || s/^(\[([^\]\\]|\\.)*\])\s*// # [...] + s/^("(?:[^"\\]*|\\.)*")\s*// # "..." + || s/^(\[(?:[^\]\\]*|\\.)*\])\s*// # [...] || s/^([^\s\Q()<>\@,;:\\".[]\E]+)\s*// || s/^([\Q()<>\@,;:\\".[]\E])\s*// and do { push(@words, $1); next; }; diff -ur MailTools-1.67/Mail/Address.pm MailTools-1.67-fix/Mail/Address.pm --- MailTools-1.67/Mail/Address.pm 2005-01-20 01:17:54.000000000 -0800 +++ MailTools-1.67-fix/Mail/Address.pm 2005-11-22 11:26:25.000000000 -0800 @@ -119,8 +119,8 @@ next; } - s/^("([^"\\]|\\.)*")\s*// # "..." - || s/^(\[([^\]\\]|\\.)*\])\s*// # [...] + s/^("(?:[^"\\]*|\\.)*")\s*// # "..." + || s/^(\[(?:[^\]\\]*|\\.)*\])\s*// # [...] || s/^([^\s\Q()<>\@,;:\\".[]\E]+)\s*// || s/^([\Q()<>\@,;:\\".[]\E])\s*// and do { push(@words, $1); next; }; Only in MailTools-1.67-fix/Mail: Address.pm~
Download (untitled) / with headers
text/plain 530b
Your patch was not on the latest version, I already had changed some things in it. Working a little further on the regexes, my choice would be: if( s/^(?:"(?:[^"\\]+|\\.)*")\s*// # "..." || s/^(?:\[(?:[^\]\\]+|\\.)*\])\s*// # [...] || s/^(?:[^\s()<>\@,;:\\".[\]]+)\s*// || s/^(?:[()<>\@,;:\\".[\]])\s*// ) { push(@words, $1); next; } Do you think this is right? More "?:" and your '*' became '+'
From: jgmyers [...] proofpoint.com
Download (untitled) / with headers
text/plain 124b
Good catch on the * to +. I believe the outermost parens cannot be ?: as that would make the $1 used later be undefined.
Oops, you're right: parens required. Use release 1.69, soon at CPAN


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.