Open
Bug 1158023
Opened 10 years ago
Updated 2 years ago
uneval of DOMException can fail to parse
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
NEW
People
(Reporter: jruderman, Unassigned)
References
Details
(Keywords: testcase)
> uneval(new DOMException("#", "%"))
(new %("#", "", 1))
Why is the second argument being treated as if it's a constructor name?
Comment 1•10 years ago
|
||
> Why is the second argument being treated as if it's a constructor name?
new DOMException(x, y) creates a DOMException with .message == x and .name == y.
uneval does toSource.
DOMException has Error.prototype on its prototype chain.
So we end up invoking Error.prototype.toSource on this DOMException.
Which leads us to a simple way to reproduce this problem without DOMException:
uneval(Object.create(Error.prototype, { name: { value: "%" } }))
So what's happening is that Error.prototype.toSource (exn_toSource) never checks for thisval being an Error and just happily gets its .name, .message, .fileName, etc and produces a string from all that.
Component: DOM → JavaScript Engine
Comment 2•10 years ago
|
||
Or heck, here's another simple example:
var e = new Error(); e.name = "%"; uneval(e)
Updated•7 years ago
|
Has Regression Range: --- → irrelevant
status-firefox40:
affected → ---
Updated•2 years ago
|
Severity: minor → S4
You need to log in
before you can comment on or make changes to this bug.
Description
•