Closed
Bug 165353
Opened 23 years ago
Closed 21 years ago
Regular Expression parsed incorrectly
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: franky, Assigned: rogerl)
References
Details
(Whiteboard: [QA note: I expect this to be fixed by the big patch in bug 85721])
Attachments
(1 file)
|
211 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826
Try the following piece of javascript:
<script>
re = /^(([a-z0-9]+[\-]*)*[a-z0-9]\.)+[a-z]{2,}$/i;
alert (re.test("www.netscape.com"));
</script>
IE says "true", which is correct.
Mozilla says "false", which is incorrect.
This problem seems to be there since a long time ago. I've tried Netscape 6.2
(that's the oldest build I've got on my computer) and the same problem occurs.
Reproducible: Always
Steps to Reproduce:
1.Paste the above Javascript in an HTML document
2.Open the document with the browser
Actual Results:
An alert box saying "false"
Expected Results:
An alert box saying "true"
Forgot to mention - with the above regular expression, if you test with
"w.netscape.com" (or anthing with just 1 character before the first dot), you'll
get "true".
Comment 2•23 years ago
|
||
Linux trunk build 20020827 says "false"
Updated•23 years ago
|
OS: Windows 2000 → All
Probably a related problem:
<script>
re = /^([a-z]+)*[a-z]$/;
alert (re.test("ab"));
</script>
Any 2-alpha test string will return "false". 1-alpha is fine (returns true), and
anything with 3 or more alphabets is also fine. Very strange...
OS: All → Windows 2000
Updated•23 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 2000 → All
Hardware: PC → All
Comment 4•23 years ago
|
||
Confirming report in the current JS Shell:
js> re = /^(([a-z0-9]+[\-]*)*[a-z0-9]\.)+[a-z]{2,}$/i;
js> s = "www.netscape.com"
js> re.exec(s);
null
js> s = "ww.netscape.com"
js> re.exec(s);
null
js> s = "w.netscape.com"
js> re.exec(s);
w.netscape.com,netscape.,netscap
----------------------- COMPARE Perl 5.6.1: -----------------------
perl -e 'if("www.netscape.com" =~
m/^(([a-z0-9]+[\-]*)*[a-z0-9]\.)+[a-z]{2,}$/i){print("$&,$1,$2");} else
{print("NO MATCH");}'
www.netscape.com,netscape.,netscap
perl -e 'if("ww.netscape.com" =~
m/^(([a-z0-9]+[\-]*)*[a-z0-9]\.)+[a-z]{2,}$/i){print("$&,$1,$2");} else
{print("NO MATCH");}'
ww.netscape.com,netscape.,netscap
perl -e 'if("w.netscape.com" =~
m/^(([a-z0-9]+[\-]*)*[a-z0-9]\.)+[a-z]{2,}$/i){print("$&,$1,$2");} else
{print("NO MATCH");}'
w.netscape.com,netscape.,netscap
Comment 5•23 years ago
|
||
Testcase added to JS testsuite:
mozilla/js/tests/ecma_3/RegExp/regress-165353.js
I believe the fix for this bug is already subsumed under the big
RegExp rewrite. This is the patch posted in SpiderMonkey bug 85721.
Why do I say this? Because this patch has already been committed
to Rhino, and all five sections of the above test pass in Rhino -
Updated•23 years ago
|
Whiteboard: [QA note: I expect this to be fixed by the big patch in bug 85721]
Depends on: RegExpPerf
This bug still exist in the latest 1.4 release. Is it going to be fixed any time
soon?
Comment 8•21 years ago
|
||
Fixed by the landing and mop-up for bug 85721.
/be
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•