Closed Bug 1337564 Opened 7 years ago Closed 5 years ago

{ "__proto__": null } in an eval'ed string fails to create an object without prototype in some situations

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: claude.pache, Assigned: evilpie)

References

Details

(Keywords: triage-deferred)

Attachments

(2 files)

Testcase

    var x = eval('   ({ "__proto__" : null })');
    Object.getPrototypeOf(x) === null; // true
    ({}).hasOwnProperty.call(x, '__proto__'); // false

    var y = eval('({ "__proto__" : null })');
    Object.getPrototypeOf(y) === Object.prototype; // true
    ({}).hasOwnProperty.call(y, '__proto__'); // true


This is a interesting side-effect of Bug 578216.
Blocks: 578216
And a related parser issue:
---
js> eval('({ "__proto__" : null, "__proto__" : null })');
({__proto__:null})
js> eval('  ({ "__proto__" : null, "__proto__" : null })');
typein:1:25 SyntaxError: property name __proto__ appears more than once in object literal:
typein:1:25   ({ "__proto__" : null, "__proto__" : null })
typein:1:25 .........................^
Stack:
  @typein:2:1
---
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached patch Potential FixSplinter Review
Huhu what a curious bug! I wonder if there are any other differences lurking somewhere. We need to test the performance objects with a lot of properties before landing this.
Keywords: triage-deferred
Priority: -- → P3
Assignee: nobody → evilpies
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/f64d18fe9b93
Don't use JSON behavior for __proto__ with eval. r=jwalden
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: