Closed
Bug 513020
Opened 15 years ago
Closed 13 years ago
[Regexp] String.match with global flag does not return null when nothing is found
Categories
(Tamarin Graveyard :: Virtual Machine, defect, P2)
Tamarin Graveyard
Virtual Machine
Tracking
(Not tracked)
RESOLVED
WONTFIX
Q1 12 - Brannan
People
(Reporter: brbaker, Assigned: pnkfelix)
References
Details
(Whiteboard: has-patch, WE:3073429, WE:3069935)
Attachments
(2 files, 2 obsolete files)
(deleted),
text/plain
|
Details | |
(deleted),
patch
|
treilly
:
review+
lhansen
:
superreview+
|
Details | Diff | Splinter Review |
Steps to reproduce:
1. Create a string and a pattern with the global parameter that should NOT match:
var line:String = "aaa";
var pattern:RegExp = /bbb/gi;
2. Use String.match:
var result = line.match(pattern);
3. Evaluate the result:
if(result == null)
{
trace("Result is null");
}
else
{
trace("Result is not null");
}
Actual Results:
"Result is not null"
Expected Results:
"Result is null". The documentation states that "If no match is found, the method returns null. If you pass no value (or an undefined value) as the pattern parameter, the method returns null."
The Flex Debugger tells me that <result> is an Array of length 0. It should however be <null>
Flags: flashplayer-triage+
Flags: flashplayer-qrb?
Reporter | ||
Comment 1•15 years ago
|
||
Test should trace out that the "Result is null", but currently the result is NOT null
Reporter | ||
Comment 2•15 years ago
|
||
Transferred from JIRA ASC-3824 http://bugs.adobe.com/jira/browse/ASC-3824
Transferred comments:
Brent Baker - [07/31/09 09:02 AM ]
String.match() will properly return null when no match is made if the global flag is not enabled. Bug appears to be a problem when no matches made bug global flag is enabled.
Comment 3•15 years ago
|
||
Any fix for this bug will likely need version-checking for backwards compatibility.
Reporter | ||
Updated•15 years ago
|
Flags: in-testsuite?
Updated•15 years ago
|
Flags: flashplayer-needsversioning+
Updated•15 years ago
|
Target Milestone: flash10.1 → Future
Updated•15 years ago
|
Priority: P3 → --
Comment 4•15 years ago
|
||
Change of behaviour, likely candidate for version check.
Updated•15 years ago
|
Status: NEW → ASSIGNED
Updated•15 years ago
|
Whiteboard: Has patch
Jason, land in TR for Brannan. Note that a SWF version check is required for this change.
Assignee: rreitmai → jason.boyer
Flags: flashplayer-bug+
Priority: -- → P3
Whiteboard: Has patch → has-patch
Target Milestone: Future → Q1 12 - Brannan
Comment 6•13 years ago
|
||
Attachment #412517 -
Attachment is obsolete: true
Attachment #558890 -
Flags: superreview?
Attachment #558890 -
Flags: review?(treilly)
Comment 7•13 years ago
|
||
Comment on attachment 558890 [details] [diff] [review]
Rebased patch and added swf version check. New test case.
Please use NULL instead of 0.
How does the test harness know to test both branches of the test case?
Attachment #558890 -
Flags: review?(treilly) → review+
Reporter | ||
Comment 8•13 years ago
|
||
(In reply to Tommy Reilly from comment #7)
> How does the test harness know to test both branches of the test case?
If you add a file test/acceptance/as3/RegExp/bug_513020.as.avm_args and it has the following line:
USES_SWFVERSION
The test harness will then execute the test multiple times using "-swfversion 9 " to "-swfversion 15", take a look at test/acceptance/regress/bug_551587_2.as.avm_args
Comment 9•13 years ago
|
||
OK, I changed 0 to NULL, and added the .avm_args file so that the test case will run against all versions of SWF that we test.
Attachment #558890 -
Attachment is obsolete: true
Attachment #559292 -
Flags: superreview?(lhansen)
Attachment #559292 -
Flags: review?(treilly)
Attachment #558890 -
Flags: superreview?
Updated•13 years ago
|
Attachment #559292 -
Flags: superreview?(lhansen) → superreview+
Comment 10•13 years ago
|
||
Comment on attachment 559292 [details] [diff] [review]
Fixes based on code review
+1 prevailing style is to leave off curly braces on one liner if but I'm not a stickler for such things.
Attachment #559292 -
Flags: review?(treilly) → review+
Blocks: regex-upgrade
Assignee | ||
Updated•13 years ago
|
Assignee: jason.boyer → fklockii
Comment 11•13 years ago
|
||
changeset: 6749:e2cc6403121d
user: Jason Boyer <jason.boyer@adobe.com>
summary: Bug 513020: allow null array return (author=jason.boyer, r=treilly, sr=lhansen, push=fklockii).
http://hg.mozilla.org/tamarin-redux/rev/e2cc6403121d
Assignee | ||
Updated•13 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Comment 12•13 years ago
|
||
Felix, the consensus opinion is that this should be reverted in Brannan and closed as wontfix. It appears this change impacts at least one third party library.
paraphrasing:
The String.match() behavior that has been in place for 8+ years. Its unlikely we are going to recruit significant #s of new ECMAScript authors over to AS3 development at this time, but we can cause pain to a significant # of our existing AS3 developers via this change. The cost/benefit ratio seems to favor backing this out and never fixing it.
Status: RESOLVED → REOPENED
Priority: P3 → P2
Resolution: FIXED → ---
Assignee | ||
Comment 13•13 years ago
|
||
Okay will revert.
Assignee | ||
Updated•13 years ago
|
Whiteboard: has-patch → has-patch, WE:3073429, WE:3069935
Assignee | ||
Comment 14•13 years ago
|
||
It seems very strange to me that the JIRA bug (linked in comment 2) seems like it is quoting documentation that sounds like ours but does not match ours.
I cannot figure out if our documentation was changed to match the actual behavior of the runtime in the time since the JIRA bug was filed, or if the original filer of the bug did not properly quote our documentation (or perhaps was not quoting our documentation at all).
Anyway, like I said, "will revert."
Assignee | ||
Comment 15•13 years ago
|
||
(In reply to Felix S Klock II from comment #14)
> I cannot figure out if our documentation was changed to match the actual
> behavior of the runtime in the time since the JIRA bug was filed
If this is what happened, then we still have a documentation bug, because now the documentation does not match the case of what happens when the 'g' parameter is *not* on the regexp, as Brent noted in comment 2.
Concrete illustration at avmshell repl (with JSON stringification so that its crystal clear which cases the array comes up in):
avmplus interactive shell
Type '?' for help
> var line = "aaa"
aaa
> var patG = /bbb/gi
/bbb/gi
> var pat1 = /bbb/i
/bbb/i
> JSON.stringify(line.match(patG))
[]
> JSON.stringify(line.match(pat1))
null
Comment 16•13 years ago
|
||
changeset: 7137:868c2d2d2e70
user: Felix S Klock II <fklockii@adobe.com>
summary: Bug 513020: backout e2cc6403121d reverting its "fix"; setting old behavior in stone (r=fklockii).
http://hg.mozilla.org/tamarin-redux/rev/868c2d2d2e70
Assignee | ||
Comment 17•13 years ago
|
||
(the backout removed the test that jason added. it would be good to put in a test for the behavior we are setting in stone.)
Comment 18•13 years ago
|
||
Brent, please add a test.
Comment 19•13 years ago
|
||
changeset: 7148:8c8106fbe824
user: Brent Baker <brbaker@adobe.com>
summary: Bug 513020: add testcase that shows null and empty array being returned during a non-match with with /i and /gi
http://hg.mozilla.org/tamarin-redux/rev/8c8106fbe824
Reporter | ||
Updated•13 years ago
|
Flags: in-testsuite? → in-testsuite+
Assignee | ||
Updated•13 years ago
|
Status: REOPENED → RESOLVED
Closed: 13 years ago → 13 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•13 years ago
|
Resolution: FIXED → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•