Closed
Bug 596466
Opened 14 years ago
Closed 14 years ago
Major regExp.exec(string) and regExp.test(string) bug
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: rog3rli, Unassigned)
References
()
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100824 Firefox/3.6.9
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100824 Firefox/3.6.9
I'm a programmer, and I'm using regExp's to simplify my life in a chat thing. Basically, ":blue:" in a chat will essentially be replaced with "". because there can be all sorts of colors, I can't use replace. Instead, I used regExp.exec(string). However, there is a major bug where every other time, the regExp.exec returns null even if there IS a match. If the chat is ":blue:", the response will alternate as :blue:,null,:blue:,null,etc. If the chat is ":blue: :red:" (e.g. two color blocks) the response will go :blue:,null,null,:blue:,null,null and so on. Basically, if there are 'x' color blocks defined, the .exec will work every x+1 times, and the other times it will not find a match. this also happens with regExp.test. I have gone through my code hundreds of times, and finally, I decided to run it in Opera. It works PERFECTLY fine. even in IE, it works. So i had to assume it was some bug with Firefox.
I'm not sure if it's just me. However, I have uploaded an html file onto http://jsbattle.tablocks.com/Untitled-1.html (the subdomain had a different purpose, but i figured i would put it here), and it will alert :blue: and null (at least for me). You can view the source code. An important note is that this .exec and .test glitch only happens inside functions. for example, regExp.exec twice just in a script tag will run fine, but while in a function abc() {regExp.exec} and executing abc(); abc(); it'll glitch out. I have not run extensive tests to see when this glitch occurs, this is all I know. Please help, Mozilla Developers.
Reproducible: Always
Steps to Reproduce:
to view this problem, I have uploaded a page onto:
http://jsbattle.tablocks.com/Untitled-1.html
You can view the source code and see how the regExp's nested in a function plays out. Also, note that taking these regExp's out of the function and just executing them directly does not result in the bug.
Actual Results:
it alerted ":blue:" and then null
Expected Results:
alert ":blue:" and then ":blue:" again, seeing as the code is the exact same time.
http://jsbattle.tablocks.com/Untitled-1.html
An example test page, you can view the source code and understand what is wrong. I believe this is rather severe, as .exec and .test on regExp's are major features. Yes, it is a Firefox bug, does not happen in IE or anything else. (I haven't tested this on Thunderbird, the other of Mozilla's browsers)
Comment 1•14 years ago
|
||
The testcase works for me on trunk.The spec was changed for ES5 as the previous behaviour confused people and wasn't always implemented properly.
Assignee: nobody → general
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Resolution: --- → DUPLICATE
Version: unspecified → 1.9.2 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•