Bug 51206 - grouping regexp matching incorrectly
Summary: grouping regexp matching incorrectly
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.6
: P2 Normal
Assignee: Nobody
URL: http://interview.tiddlyspace.com/
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-16 12:30 PST by Chris Dent
Modified: 2010-12-17 12:47 PST (History)
4 users (show)

See Also:


Attachments
reduction of the problem (590 bytes, text/plain)
2010-12-16 12:31 PST, Chris Dent
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dent 2010-12-16 12:30:26 PST
At the above URL some JavaScript is used to determine which items to display. If you compare the resulting page in webkit nightly with Firefox you'll see the issue.

I've reduced this down to this code (also attached), which will produce different results when run in the consoles of nightlies or Firefox (it can also be run, returning the correct results, against node.js):

-=-=-
var text = "HelloThere\n\
[[How did you first discover TiddlyWiki?]]\n\
[tag[band]]\n\
[[What was it about TiddlyWiki that captured your interest?]]\n\
[[Which aspects of TiddlyWiki do you find most valuable?]]\n\
"

// This one does not work in webkit's console.
var re = /([^\s\[\]]+)|(?:\[([\w]+)\[([^\]]+)\]\])|(?:\[\[([^\]]+)\]\])/mg;
// This one works in webkit's console.
//var re = /([^\s\[\]]+)|(?:\[\[([^\]]+)\]\])|(?:\[([\w]+)\[([^\]]+)\]\])/mg;

var match = re.exec(text);
while (match) {
    console.log(match[1], match[2], match[3], match[4]);
    match = re.exec(text);
}

-=-=-

Changing the ordering of group in re to be like the second re in the snippet gets the expected results, so that's perhaps a clue.

This is a regression of some kind, likely within the last two or three weeks or so.
Comment 1 Chris Dent 2010-12-16 12:31:56 PST
Created attachment 76799 [details]
reduction of the problem
Comment 2 Alexey Proskuryakov 2010-12-17 12:34:06 PST
> If you compare the resulting page in webkit nightly with Firefox you'll see the issue.

I don't see a difference between r74228 and Firefox 3.6.13. Running the reduce test case also gives identical results:

-----------------------
HelloThere undefined undefined undefined
undefined undefined undefined "How did you first discover TiddlyWiki?"
undefined "tag" "band" undefined
undefined undefined undefined "What was it about TiddlyWiki that captured your interest?"
undefined undefined undefined "Which aspects of TiddlyWiki do you find most valuable?"
null
-----------------------

Please re-open with more information if you can still observe the problem with the latest nightly.
Comment 3 Chris Dent 2010-12-17 12:47:09 PST
Worksforme now too, since getting 74228. I was on 73886.

I'm assuming this was the fix http://trac.webkit.org/changeset/73962 ?

Thanks.