Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABNF: escaped-char rule included potentially unwanted /(SOLIDUS) character #83

Closed
springcomp opened this issue Jul 13, 2022 · 3 comments

Comments

@springcomp
Copy link
Contributor

springcomp commented Jul 13, 2022

From the grammar:

literal           = "`" json-value "`"

; The ``json-value`` is any valid JSON value with the one exception that the
; ``%x60`` character must be escaped.  While it's encouraged that implementations
; use any existing JSON parser for this grammar rule (after handling the escaped
; literal characters), the grammar rule is shown below for completeness::

json-value =/ json-quoted-string
json-quoted-string = %x22 1*(unescaped-literal / escaped-literal) %x22

escaped-literal   = escaped-char / (escape %x60)
escaped-char      = escape (
                        %x22 /          ; "    quotation mark  U+0022
                        %x5C /          ; \    reverse solidus U+005C
                        %x2F /          ; /    solidus         U+002F
                        %x62 /          ; b    backspace       U+0008
                        %x66 /          ; f    form feed       U+000C
                        %x6E /          ; n    line feed       U+000A
                        %x72 /          ; r    carriage return U+000D
                        %x74 /          ; t    tab             U+0009
                        %x75 4HEXDIG )  ; uXXXX                U+XXXX

The / (U+002F SOLIDUS) character is included in the escaped-char rule but I cannot understand why.

To me the / character does not need escaping and thus should be removed from this list.

@innovate-invent
Copy link
Collaborator

I believe that was just copied from the top google hit for json abnf

Is this a cross compatibility thing where some environment uses /t for escaping?

@springcomp
Copy link
Contributor Author

I believe that was just copied from the top google hit for json abnf

Is this a cross compatibility thing where some environment uses /t for escaping?

You are right.
JSON.org wants it in its grammar.

@springcomp
Copy link
Contributor Author

springcomp commented Jul 13, 2022

Seems to come from a need to escape / in JavaScript when it appears in HTML 🤯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants