Regular Expression parsed incorrectly

RESOLVED FIXED

Status

()

Core
JavaScript Engine
--
major
RESOLVED FIXED
16 years ago
14 years ago

People

(Reporter: franky, Assigned: rogerl (gone))

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [QA note: I expect this to be fixed by the big patch in bug 85721])

Attachments

(1 attachment)

(Reporter)

Description

16 years ago
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"
(Reporter)

Comment 1

16 years ago
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

16 years ago
Created attachment 97116 [details]
reporter's testcase

Linux trunk build 20020827 says "false"

Updated

16 years ago
OS: Windows 2000 → All
(Reporter)

Comment 3

16 years ago
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
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 2000 → All
Hardware: PC → All

Comment 4

16 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

16 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

16 years ago
Whiteboard: [QA note: I expect this to be fixed by the big patch in bug 85721]

Updated

16 years ago
Depends on: 85721
(Reporter)

Comment 6

15 years ago
This bug still exist in the latest 1.4 release. Is it going to be fixed any time
soon?

Comment 7

15 years ago
Hopefully - waiting for a code review on the patch for bug 85721
Fixed by the landing and mop-up for bug 85721.

/be
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.