You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also test this in your browser by running this round trip of encoding and evaluation:
constjs="export default "+JSON.stringify("\u2028\u2029")consturl=awaitURL.createObjectURL(newBlob([js],{type: "text/javascript"}))const{default: evaluated}=awaitimport(url)console.log(evaluated.split("").map(c=>c.charCodeAt(0).toString(16)))// should output ["2028", "2029"]
However, I noticed that running this through the JS parser of this library causes an error, as it doesn't consider the string to be terminated (same behavior as old browsers). I think for practical purposes the parser should adopt the behavior of modern browsers.
The text was updated successfully, but these errors were encountered:
So historically trying to use the output of
JSON.stringify("\u2028")
as JavaScript would break evaluation because JS would consider that character a newline, hence the string would be unterminated. But since then modern browsers have changed to not consider it a line break, as documented here:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#issue_with_plain_json.stringify_for_use_as_javascript
You can also test this in your browser by running this round trip of encoding and evaluation:
However, I noticed that running this through the JS parser of this library causes an error, as it doesn't consider the string to be terminated (same behavior as old browsers). I think for practical purposes the parser should adopt the behavior of modern browsers.
The text was updated successfully, but these errors were encountered: