Feature Request: Make ECMA262 a superset of JSON

Claude Pache claude.pache at gmail.com
Fri Sep 30 06:43:10 UTC 2016

Besides U+2028 and U+2029, there is also the __proto__ key, which has a special meaning in JS as implemented in browser. That prevents definitely to "safely" embed arbitrary JSON within JS.


> Le 29 sept. 2016 à 23:21, Richard Gibson <richard.gibson at gmail.com> a écrit :
> ECMAScript claims JSON as a subset twice in https://tc39.github.io/ecma262/#sec-json.parse <https://tc39.github.io/ecma262/#sec-json.parse> , but (as has been well-documented) that is not true because it JSON strings can contain unescaped U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR while ECMAScript strings cannot. Mark Miller alludes to a pre-ES5 push for allowing them (which ultimately failed) in https://esdiscuss.org/topic/json-stringify-script#content-17 <https://esdiscuss.org/topic/json-stringify-script#content-17> , and posits that a repeat today would also fail. Having never seen a windmill that didn't need slaying, I hereby make the attempt.
> Aside from slightly simplifying the spec (by eliminating the need for a production specific to JSON.parse) and retroactively validating its claims, such a change to _DoubleStringCharacter_ and _SingleStringCharacter_ would allow safely embedding arbitrary JSON directly within ECMAScript, a request which has been made before in the context of source concatenation/construction.
> User-visible effects from the change would be limited to the absence of SyntaxError s from code like `eval(' "\u2028" ')` or its raw-text equivalent.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160930/666cb106/attachment.html>

More information about the es-discuss mailing list