From 15c0d1879fbef24cbf04505008609643d8a28041 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Fri, 2 Oct 2026 07:43:19 +0200 Subject: [PATCH 1/2] docs: state that a root string starting with U+FEFF is quoted --- SPEC.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SPEC.md b/SPEC.md index 5886755..676f3ec 100644 --- a/SPEC.md +++ b/SPEC.md @@ -424,6 +424,7 @@ Encoders MUST quote a string value if any of the following is true: - It contains the relevant delimiter – the active delimiter for inline array values, tabular row cells, and keyed entry-row cells; the document delimiter for object field values (§11.1, which is authoritative for delimiter-aware quoting). - It equals "-" or starts with "-" (any hyphen at position 0). - It equals "#" or starts with "#" (any number sign at position 0). +- It is a root primitive (§5) and starts with U+FEFF (§12). Otherwise, the string MAY be emitted without quotes. Unicode, emoji, and strings with internal (non-leading/trailing) spaces are safe unquoted provided they do not violate the conditions. From 5bf291b483ab530354011f10bededdda5c28a047 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Fri, 2 Oct 2026 07:43:19 +0200 Subject: [PATCH 2/2] test: cover a root string starting with U+FEFF --- tests/fixtures/encode/primitives.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/fixtures/encode/primitives.json b/tests/fixtures/encode/primitives.json index 9d6041a..826c95e 100644 --- a/tests/fixtures/encode/primitives.json +++ b/tests/fixtures/encode/primitives.json @@ -273,6 +273,14 @@ "input": "#hello", "expected": "\"#hello\"", "specSection": "7.2" + }, + { + "name": "quotes a root string starting with U+FEFF", + "input": "\ufeff8", + "expected": "\"\ufeff8\"", + "specSection": "7.2", + "note": "Unquoted, a decoder would remove the U+FEFF as a byte-order mark (§12) and read the number 8", + "minSpecVersion": "4.1" } ] }