From eb727477b3f7e4aa878635d39257753f0840811b Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Sat, 15 Jun 2024 09:52:20 +0100 Subject: [PATCH] Remove broken TOML 1.1 "Unicode keys" feature --- bench_test.go | 3 +- .../toml-test/tests/valid/key/unicode.json | 44 ------------------- .../toml-test/tests/valid/key/unicode.toml | 15 ------- lex.go | 21 +-------- toml_test.go | 3 +- 5 files changed, 4 insertions(+), 82 deletions(-) delete mode 100644 internal/toml-test/tests/valid/key/unicode.json delete mode 100644 internal/toml-test/tests/valid/key/unicode.toml diff --git a/bench_test.go b/bench_test.go index fd8ce13e..61991eb1 100644 --- a/bench_test.go +++ b/bench_test.go @@ -79,8 +79,7 @@ func BenchmarkEncode(b *testing.B) { // "next" version of TOML. switch path { case "valid/string/escape-esc.toml", "valid/datetime/no-seconds.toml", - "valid/string/hex-escape.toml", "valid/inline-table/newline.toml", - "valid/key/unicode.toml": + "valid/string/hex-escape.toml", "valid/inline-table/newline.toml": return nil } diff --git a/internal/toml-test/tests/valid/key/unicode.json b/internal/toml-test/tests/valid/key/unicode.json deleted file mode 100644 index 25258ae9..00000000 --- a/internal/toml-test/tests/valid/key/unicode.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "a‍b": { - "type": "string", - "value": "zwj" - }, - "tiếng-Việt": [ - { - "tiəŋ˧˦": { - "viət̚˧˨ʔ": { - "type": "string", - "value": "north" - } - } - }, - { - "tiəŋ˦˧˥": { - "viək̚˨˩ʔ": { - "type": "string", - "value": "central" - } - } - } - ], - "ÅÅ": { - "type": "string", - "value": "U+00C5 U+0041 U+030A" - }, - "€": { - "type": "string", - "value": "Euro" - }, - "中文": { - "中文": { - "中文": { - "type": "string", - "value": "Chinese language" - } - } - }, - "😂": { - "type": "string", - "value": "rofl" - } -} diff --git a/internal/toml-test/tests/valid/key/unicode.toml b/internal/toml-test/tests/valid/key/unicode.toml deleted file mode 100644 index e4137b63..00000000 --- a/internal/toml-test/tests/valid/key/unicode.toml +++ /dev/null @@ -1,15 +0,0 @@ -# TOML 1.1 supports Unicode for bare keys. - -€ = 'Euro' -😂 = "rofl" -a‍b = "zwj" -ÅÅ = "U+00C5 U+0041 U+030A" - -[中文] -中文 = {中文 = "Chinese language"} - -[[tiếng-Việt]] -tiəŋ˧˦.viət̚˧˨ʔ = "north" - -[[tiếng-Việt]] -tiəŋ˦˧˥.viək̚˨˩ʔ = "central" diff --git a/lex.go b/lex.go index 6878d9d6..cd9de46a 100644 --- a/lex.go +++ b/lex.go @@ -1265,23 +1265,6 @@ func isBinary(r rune) bool { return r == '0' || r == '1' } func isOctal(r rune) bool { return r >= '0' && r <= '7' } func isHex(r rune) bool { return (r >= '0' && r <= '9') || (r|0x20 >= 'a' && r|0x20 <= 'f') } func isBareKeyChar(r rune, tomlNext bool) bool { - if tomlNext { - return (r >= 'A' && r <= 'Z') || - (r >= 'a' && r <= 'z') || - (r >= '0' && r <= '9') || - r == '_' || r == '-' || - r == 0xb2 || r == 0xb3 || r == 0xb9 || (r >= 0xbc && r <= 0xbe) || - (r >= 0xc0 && r <= 0xd6) || (r >= 0xd8 && r <= 0xf6) || (r >= 0xf8 && r <= 0x037d) || - (r >= 0x037f && r <= 0x1fff) || - (r >= 0x200c && r <= 0x200d) || (r >= 0x203f && r <= 0x2040) || - (r >= 0x2070 && r <= 0x218f) || (r >= 0x2460 && r <= 0x24ff) || - (r >= 0x2c00 && r <= 0x2fef) || (r >= 0x3001 && r <= 0xd7ff) || - (r >= 0xf900 && r <= 0xfdcf) || (r >= 0xfdf0 && r <= 0xfffd) || - (r >= 0x10000 && r <= 0xeffff) - } - - return (r >= 'A' && r <= 'Z') || - (r >= 'a' && r <= 'z') || - (r >= '0' && r <= '9') || - r == '_' || r == '-' + return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') || + (r >= '0' && r <= '9') || r == '_' || r == '-' } diff --git a/toml_test.go b/toml_test.go index 7713b857..915a51f8 100644 --- a/toml_test.go +++ b/toml_test.go @@ -263,8 +263,7 @@ func TestTomlNextFails(t *testing.T) { "valid/string/escape-esc", "valid/datetime/no-seconds", "valid/string/hex-escape", - "valid/inline-table/newline", - "valid/key/unicode") + "valid/inline-table/newline") } func runTomlTest(t *testing.T, includeNext bool, wantFail ...string) {