From c60f71171b376eddd9f57c04d23293a4ac923684 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 19 Jun 2023 20:51:42 +0300 Subject: [PATCH 1/4] Add negative-start rule --- spec/message.abnf | 6 +++--- spec/syntax.md | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spec/message.abnf b/spec/message.abnf index 14ae860879..a3ae393066 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -36,11 +36,11 @@ quoted-char = %x0-5B ; omit \ / %x7D-D7FF ; omit surrogates / %xE000-10FFFF -; based on https://www.w3.org/TR/xml/#NT-Nmtoken, -; but cannot start with U+002D HYPHEN-MINUS or U+003A COLON ":" -unquoted = unquoted-start *name-char +; based on https://www.w3.org/TR/xml/#NT-Nmtoken +unquoted = (unquoted-start / negative-start) *name-char unquoted-start = name-start / DIGIT / "." / %xB7 / %x300-36F / %x203F-2040 +negative-start = "-" ( DIGIT / "." ) ; reserve additional sigils for future use reserved = reserved-start reserved-body diff --git a/spec/syntax.md b/spec/syntax.md index 940e480204..40d8d48847 100644 --- a/spec/syntax.md +++ b/spec/syntax.md @@ -463,8 +463,9 @@ The characters `\` and `|` MUST be escaped as `\\` and `\|`. **_Unquoted_** literals have a much more restricted range that is intentionally close to the XML's [Nmtoken](https://www.w3.org/TR/xml/#NT-Nmtoken), -with the restriction that it MUST NOT start with `-` or `:`, -as those would conflict with _function_ start characters. +with the restrictions that it MUST NOT start with `:`, +and when starting with `-`, must be followed by a `.` or a digit. +These restrictions are required not to conflict with _function_ start characters. All code points are preserved. @@ -477,9 +478,10 @@ quoted-char = %x0-5B ; omit \ / %x7D-D7FF ; omit surrogates / %xE000-10FFFF -unquoted = unquoted-start *name-char +unquoted = (unquoted-start / negative-start) *name-char unquoted-start = name-start / DIGIT / "." / %xB7 / %x300-36F / %x203F-2040 +negative-start = "-" ( DIGIT / "." ) ``` ### Names From f1166f5a9202c2a516f1aac5133e4a5fff95561d Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 19 Jun 2023 23:53:52 +0300 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Addison Phillips --- spec/message.abnf | 2 +- spec/syntax.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/message.abnf b/spec/message.abnf index a3ae393066..c332fe36ef 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -36,7 +36,7 @@ quoted-char = %x0-5B ; omit \ / %x7D-D7FF ; omit surrogates / %xE000-10FFFF -; based on https://www.w3.org/TR/xml/#NT-Nmtoken +; similar to https://www.w3.org/TR/xml/#NT-Nmtoken unquoted = (unquoted-start / negative-start) *name-char unquoted-start = name-start / DIGIT / "." / %xB7 / %x300-36F / %x203F-2040 diff --git a/spec/syntax.md b/spec/syntax.md index 40d8d48847..8bd073138f 100644 --- a/spec/syntax.md +++ b/spec/syntax.md @@ -462,10 +462,10 @@ except for surrogate code points U+D800 through U+DFFF. The characters `\` and `|` MUST be escaped as `\\` and `\|`. **_Unquoted_** literals have a much more restricted range that -is intentionally close to the XML's [Nmtoken](https://www.w3.org/TR/xml/#NT-Nmtoken), -with the restrictions that it MUST NOT start with `:`, -and when starting with `-`, must be followed by a `.` or a digit. -These restrictions are required not to conflict with _function_ start characters. +is intentionally close to XML's [Nmtoken](https://www.w3.org/TR/xml/#NT-Nmtoken). +To make _unquoted_ literals distinct from _function_ names, +a literal MUST be quoted if it begins with a `:` +or if it begins with a `-` that is **not** followed by a `.` or a digit. All code points are preserved. From 686e99c067abb7d8d5c65feabc71e3be87236240 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Fri, 30 Jun 2023 04:10:30 +0200 Subject: [PATCH 3/4] Merge negative-start into unquoted-start --- spec/message.abnf | 4 ++-- spec/syntax.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/message.abnf b/spec/message.abnf index c332fe36ef..0268f4895d 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -37,10 +37,10 @@ quoted-char = %x0-5B ; omit \ / %xE000-10FFFF ; similar to https://www.w3.org/TR/xml/#NT-Nmtoken -unquoted = (unquoted-start / negative-start) *name-char +unquoted = unquoted-start *name-char unquoted-start = name-start / DIGIT / "." / %xB7 / %x300-36F / %x203F-2040 -negative-start = "-" ( DIGIT / "." ) + / "-" ( DIGIT / "." ) ; reserve additional sigils for future use reserved = reserved-start reserved-body diff --git a/spec/syntax.md b/spec/syntax.md index 8bd073138f..ae4e9a0c8c 100644 --- a/spec/syntax.md +++ b/spec/syntax.md @@ -478,10 +478,10 @@ quoted-char = %x0-5B ; omit \ / %x7D-D7FF ; omit surrogates / %xE000-10FFFF -unquoted = (unquoted-start / negative-start) *name-char +unquoted = unquoted-start *name-char unquoted-start = name-start / DIGIT / "." / %xB7 / %x300-36F / %x203F-2040 -negative-start = "-" ( DIGIT / "." ) + / "-" ( DIGIT / "." ) ``` ### Names From b8b0dfacfd62e6285c98b434494bf9ec5eb7b215 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sun, 2 Jul 2023 10:56:50 +0300 Subject: [PATCH 4/4] Update spec/message.abnf Co-authored-by: Addison Phillips --- spec/message.abnf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/message.abnf b/spec/message.abnf index 0268f4895d..bdb9c59b18 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -36,7 +36,8 @@ quoted-char = %x0-5B ; omit \ / %x7D-D7FF ; omit surrogates / %xE000-10FFFF -; similar to https://www.w3.org/TR/xml/#NT-Nmtoken +; literals that do not require quoting: +; containing no whitespace and with a restricted range of characters unquoted = unquoted-start *name-char unquoted-start = name-start / DIGIT / "." / %xB7 / %x300-36F / %x203F-2040