json5/json5-spec

Missing escape for /

Closed this issue · 3 comments

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).

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.

Ah, I see. Sorry to disturb, then.

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