json5 / json5-spec

The JSON5 Data Interchange Format
https://spec.json5.org
MIT License
49 stars 11 forks source link

Missing escape for / #30

Closed abrudz closed 4 years ago

abrudz commented 4 years ago

The [list of escapes]() is missing one entry:

Escape Sequence Description Code Point
\/ Solidus U+002F

This one (while not needed) is part of the JSON spec:

\/ represents the solidus character (U+002F).

jordanbtucker commented 4 years ago

Thanks for the suggestion. The reason that JSON incluldes \/ as a special escape is because JSON's list of escapes is exclusive while ES5's list is not. For example, \a is an error in JSON, but \a is just a in ES5.

The reason for JSON to include \/ in its list is, I've seen cited but don't have a source, as a way to allow </script> to appear in HTML source code as <\/script> so the browser doesn't assume it's the end of the script block.

Since JSON5 follows ES5 escape rules, the explicit listing for \/ isn't needed, so it's left out just like in the ES5 spec.

abrudz commented 4 years ago

Ah, I see. Sorry to disturb, then.

jordanbtucker commented 4 years ago

No need to apologize. I appreciate all contributions to this project. Thanks for noticing the discrepancy and bringing it here.