jmespath-community / jmespath.spec

JMESPath Specification
8 stars 3 forks source link

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

Closed springcomp closed 2 years ago

springcomp commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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