Closed Bug 350268 Opened 18 years ago Closed 18 years ago

"}" in "new Function" should cause syntax error instead of making the rest be ignored

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

VERIFIED FIXED
mozilla1.9alpha1

People

(Reporter: jruderman, Assigned: brendan)

References

Details

(Keywords: testcase)

Attachments

(1 file)

> new Function("}") function anonymous() { } > new Function("}}}}}") function anonymous() { } > new Function("alert(6); } alert(5);") function anonymous() { alert(6); } > new Function("} {") function anonymous() { } I think these should all trigger syntax errors.
Attached patch fixSplinter Review
The old "forgot to check for unconsumed tokens" gotcha. /be
Assignee: general → brendan
Status: NEW → ASSIGNED
Attachment #235536 - Flags: superreview?(shaver)
Attachment #235536 - Flags: review?(mrbkap)
OS: Mac OS X 10.4 → All
Priority: -- → P3
Hardware: Macintosh → All
Target Milestone: --- → mozilla1.8.1
Attachment #235536 - Flags: review?(mrbkap) → review+
Comment on attachment 235536 [details] [diff] [review] fix Simple and safe fix, which matches the same error case for top-level scripts. I didn't attach a diff -w, but you can see that the main change is really only four lines of added error checking and reporting, and the rest is due to existing code being indented in an else block. /be
Attachment #235536 - Flags: superreview?(shaver) → approval1.8.1?
Fixed on trunk. /be
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Depends on: 350392
I'm a little worried about checking this in on the 1.8 branch; if there's Mozilla/Netscape-only content out there this could bite it badly, and we sorta promised Gecko compat between 1.8 and 1.8.1. As an example, this broke our Tinderbox startup test, because the onload handler had a trailing '}'.
Comment on attachment 235536 [details] [diff] [review] fix We can not worry and leave this in the trunk for 1.9 only, for sure. As bz's comment implied, and as gavin pointed out, IE silently fails on trailing junk, so cross-platform web content won't care. /be
Attachment #235536 - Flags: approval1.8.1?
Target Milestone: mozilla1.8.1 → mozilla1.9alpha
No longer depends on: 350424
Depends on: 350407
Depends on: 350424
Checking in regress-350268.js; /cvsroot/mozilla/js/tests/js1_5/Regress/regress-350268.js,v <-- regress-350268.js initial revision: 1.1
Flags: in-testsuite+
Depends on: 350485
See also bug 350429, trailing "}" fails to log syntax error in some cases.
verified fixed 1.9 20060830 windows/mac*/linux
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: