Closed p5pRT closed 20 years ago
Try this sample application:
********************* #!/usr/bin/perl
$EmailAdrRe='[^\(\)\<>@\,;:\\/"\[\]\000-\040\199]+'; $EmailDomainRe='\w[\w\.\-]*\.\w+';
if($ARGV[0]=~/.*?($EmailAdrRe)\@($EmailDomainRe)/io) { print "OK\n"; } else { print "Big trouble!\n"; } ********************
This fragment is a minimal test case of a bug I found in ASSP. (http://assp.sourceforge.net)
The regular expression is supposed to check for a valid email address of the form \user@​domain\.tld. The bug occurs if the user portion ends in a digit. \a@​b\.c comes back OK. \a9a@​b\.c is fine\, too. But \a9@​b\.c fails. To make the expression work\, I had to replace $EmailAdrRe with:
$EmailAdrRe='([0-9]|[^\(\)\<>@\,;:\\/"\[\]\000-\040\199])+';
By explicitly accepting digits\, the problem was resolved.
On Wed\, Jan 28\, 2004 at 06:45:14AM -0000\, scott@pocketpurchase.com (via RT) wrote:
$EmailAdrRe='[^\(\)\<>@\,;:\\/"\[\]\000-\040\199]+';
Thank you for your report. However\, this is a bug in your script\, not in perl. \199 is not a valid octal escape\, so the regex engine is parsing it as \1\, followed by two 9s. Thus\, your character class explicitly excludes the character 9. I suspect you meant \177 instead.
Ronald
The RT System itself - Status changed from 'new' to 'open'
Thank you for your report. However\, this is a bug in your script\, not in perl. \199 is not a valid octal escape\, so the regex engine is parsing it as \1\, followed by two 9s. Thus\, your character class explicitly excludes the character 9. I suspect you meant \177 instead.
Ah\, of course. Sorry to waste your time. Thanks for the explanation.
Scott Maxwell PocketPurchase\, Inc.
@rspier - Status changed from 'open' to 'resolved'
"scott@pocketpurchase.com (via RT)" \perlbug\-followup@​perl\.org wrote: :$EmailAdrRe='[^\(\)\<>@\,;:\\/"\[\]\000-\040\199]+'; [...] :But \a9@​b\.c fails.
This is because your pattern explicitly removed '9' from the list of accepted characters: the '\nnn' notation is used to specify a character in octal\, so '\199' is interpreted the same as '\001' . '9' . '9'. I suspect you intended '\177' instead.
Note that 9 is accepted when it appears earlier in the string because of the '.*?' at the beginning of the pattern.
It is possible that perl could have been more helpful in warning you of this\, though it isn't entirely clear to me how it should detect the circumstances meriting a warning.
Hugo van der Sanden
I understand now. Thank you for the explanation.
Scott
At 07:09 PM 2/1/2004\, you wrote:
"scott@pocketpurchase.com (via RT)" \perlbug\-followup@​perl\.org wrote: :$EmailAdrRe='[^\(\)\<>@\,;:\\/"\[\]\000-\040\199]+'; [...] :But \a9@​b\.c fails.
This is because your pattern explicitly removed '9' from the list of accepted characters: the '\nnn' notation is used to specify a character in octal\, so '\199' is interpreted the same as '\001' . '9' . '9'. I suspect you intended '\177' instead.
Note that 9 is accepted when it appears earlier in the string because of the '.*?' at the beginning of the pattern.
It is possible that perl could have been more helpful in warning you of this\, though it isn't entirely clear to me how it should detect the circumstances meriting a warning.
Hugo van der Sanden
Migrated from rt.perl.org#25447 (status was 'resolved')
Searchable as RT25447$