tc39 / proposal-regexp-legacy-features

Legacy static properties of the RegExp constructor in JavaScript
Creative Commons Zero v1.0 Universal
41 stars 13 forks source link

Unsafe non-standard properties, like these, must be configurable and deletable #3

Closed erights closed 8 years ago

erights commented 8 years ago

At whatwg/javascript#29 (comment) I write

The RegExp statics are mutable global state and a global communications channel. https://github.com/google/caja/wiki/RegexpsLeakMatchGlobally Their existence must not be normative, so that a system (like SES's repairES5) that removes them produces a state that is still considered a conformant ES implementation.

Regarding the RegExp statics, the important issue is http://wiki.ecmascript.org/doku.php?id=conventions:make_non-standard_properties_configurable which we should propose and make normative. I just verified that Chrome 48.0.2564.103 ships with these statics configurable, and actually deletable, demonstrating that it is web compatible to require this.

claudepache commented 8 years ago

The RegExp statics are mutable global state and a global communications channel.

Indeed, and for that reason, I do have specified them as configurable accessor properties, so that they could be deleted.

I have a question regarding cross-realm interactions: Should special measure be taken when you apply the Regexp#exec method of one realm to a regexp constructed in another realm? (FWIW, IIRC, implementations differ: SpiderMonkey updates the static RegExp properties of the regexp's realm, while V8 updates those of RegExp#exec's realm.)

erights commented 8 years ago

Excellent question!

My inclination is that such cross-realm leakage should be explicitly banned. I'm glad you point out that browsers currently differ, where their intersection semantics would be the absence of such inter-realm leakage. This establishes that cross-browser content would not be broken by banning such inter-realm leakage.

littledan commented 8 years ago

From a V8 perspective, I think it should be possible to implement updating RegExp.prototype.exec to update the executing realm's properties. It's probably a good idea to standardize one of the two semantics (Chrome's or Firefox's) but I don't really know if there are sites which depend on one or the other.

erights commented 8 years ago

No cross-browser content can depend on either. Their intersection semantics is empty.

littledan commented 8 years ago

But the intersection does include that, within a particular realm, exec sets the property on that realm's RegExp object. So the intersection is non-empty, and that's why we are looking into standardizing these properties.

erights commented 8 years ago

yes, that I understand. That's one of the reasons why I'm now willing to let the intra-realm behavior go forward as normative-optional. The point I'm making here is only about banning cross-realm leakage.

littledan commented 8 years ago

OK, sounds good to me.

claudepache commented 8 years ago

I think that this is now properly motivated and specced in the proposal, so closing this issue.

See also #2 for the part of the proposal that currently no browser implements.