Closed
Bug 518439
Opened 15 years ago
Closed 15 years ago
Add another test to validation suite
Categories
(addons.mozilla.org Graveyard :: Developer Pages, defect)
addons.mozilla.org Graveyard
Developer Pages
Tracking
(Not tracked)
RESOLVED
FIXED
5.3
People
(Reporter: clouserw, Assigned: rjwalsh)
References
Details
Attachments
(1 file)
2.01 KB,
patch
|
clouserw
:
review+
|
Details | Diff | Splinter Review |
From email: Simply testing for Function including static strings passed as function body would lead to false positives and has very limited merit. See the setTimeout discussion https://bugzilla.mozilla.org/show_bug.cgi?id=509500 It is Function ([arg1[, arg2[, ... argN]],] functionBody) The new keyword is not required. I got two suggestions for a regular expression. Tested both against the following vectors: var allowed = [ 'Function("abc")', "Function('abc')", 'Function(d, "abc")', "Function(d, \n'abc')", "Function( d, 'abc' )", "Function(d,'abc')", 'Function(ab, cd, "a"+"bc"+"d")', ]; var bad = [ "Function(abc)", "Function('ab' + abc)", 'Function(a + "bc" + d)', 'Function(ab, \ncd)', 'Function(ab,cd)', 'Function( ab, cd )', 'Function(ab, cd, a + "bc" + d)', 'Function(ab, cd, a + "bc" + "d")', 'Function(ab, cd, "a"+"bc"+d)', 'Function(ab, cd, "a"+b+"bc"+d)', 'Function(ab, cd, a+"a"+"bc"+d)', 'Function( ab, cd, a + "a" + "bc" + d )', ]; Simple one: /\bFunction\(.*?[\w\d_]\s*?\)/sm Or javascripty (i.e. no dotall/s): /\bFunction\([\S\s]*?[\w\d_]\s*?\)/m Will work for all except: Function(ab, cd, a + "bc" + "d") Better, but more complex: /\bFunction\((?:.*?[\w\d_]|.*?,.*?(?:['"]\s*?[+]\s*?[\w_]|[\w\d_]\s*?[+]\s*?['"]).*?)\s*?\)/sm or javascripty /\bFunction\((?:[\S\s]*?[\w\d_]|[\S\s]*?,[\S\s]*?(?:['"]\s*?[+]\s*?[\w_]|[\w\d_]\s*?[+]\s*?['"])[\S\s]*?)\s*?\)/m Works for all tests Cheers Nils
Updated•15 years ago
|
Assignee: nobody → rjbuild1088
Reporter | ||
Updated•15 years ago
|
Target Milestone: 5.2 → 5.3
Assignee | ||
Comment 1•15 years ago
|
||
Using the second-to-last regex in comment #0.
Attachment #409490 -
Flags: review?(clouserw)
Reporter | ||
Updated•15 years ago
|
Attachment #409490 -
Flags: review?(clouserw) → review+
Assignee | ||
Comment 2•15 years ago
|
||
Fixed in r54982.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Updated•8 years ago
|
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•