From f07ab7f32e64a697711567983a546a15c379733e Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 28 Feb 2016 07:54:07 +0100 Subject: [PATCH] examples/json.pegjs: Fix the "unescaped" rule The "unescaped" rule was created by mechanically translating original RFC 7159 rule: unescaped = %x20-21 / %x23-5B / %x5D-10FFFF into: unescaped = [\x20-\x21\x23-\x5B\x5D-\u10FFFF] However, this mechanical translation was incorrect as PEG.js grammars don't have 6-digit Unicode escape sequences. Sequence "\u10FFFF" was interpreted as "\u10FF" followed by two "F" characters. This commit rewrites the "unescaped" rule into a form which, while not being a mechanical translation of the original rule, matches the same characters in the whole Unicode range. It also macthes textual description of string representation in RFC 7159: All Unicode characters may be placed within the quotation marks, except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F). Fixes #417. --- examples/json.pegjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/json.pegjs b/examples/json.pegjs index efa94d9..d0ba9f4 100644 --- a/examples/json.pegjs +++ b/examples/json.pegjs @@ -123,7 +123,7 @@ char escape = "\\" quotation_mark = '"' -unescaped = [\x20-\x21\x23-\x5B\x5D-\u10FFFF] +unescaped = [^\0-\x1F\x22\x5C] /* ----- Core ABNF Rules ----- */