Skip to content

Commit 8132f34

Browse files
committed
Revert "Permit more control characters in comments (#924)"
This reverts commit ab74958. I'm a simple guy. Someone reports a problem, I drink coffee and fix it. No one reports a problem? There is nothing to fix and I go drink beer. No one really reported this as a problem, but it *does* introduce needless churn for all TOML implementations and the test suite. Do we need to forbid *anything* in comments? Probably not, and in strings we probably only need to forbid \x00. But at least before it was consistent with strings, and more importantly, what everyone wrote code for, which is tested, and already works. [None of the hypotheticals](#567 (comment)) on why this is "needed" are practical issues people reported, and most aren't even fixed: a comment can still invalidate the file, you must still parse each character in a comment as some are still forbidden, the performance benefits are very close to zero they might as well be zero, and you still can't "dump whatever you like" in comments. So it doesn't *actually* change anything, it just changes "disallow this set of control characters" to ... "disallow this set of control characters" (but for a different set). That's not really a substantial or meaningful change. The only (minor) real-world issue that was reported (from the person doing the Java implementation) was that "it's substantially more complicated to parse out control characters in comments and raise an error, and this kind of strictness provides no real advantage to users". And that's not addressed at all with this, so... --- And while I'm at it, let me have a complaint about how this was merged: 1. Two people, both of whom actually maintain implementations, say they don't like this change. 2. This is basically ignored. 3. Three people continue written a fairly large number of large comments, so anyone who wasn't already interested in this change unsubscribes and/or goes 🤷 4. "Consensus". Sometimes I feel TOML attracts people who like to argue things from a mile-high ivory tower with abstract arguments that have only passing familiarity with any actual pragmatic reality. Fixes #995
1 parent 23c3fb7 commit 8132f34

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## unreleased
44

55
- Clarify Unicode and UTF-8 references.
6-
- Relax comment parsing; most control characters are again permitted.
76
- Allow newline after key/values in inline tables.
87
- Allow trailing comma in inline tables.
98
- Clarify where and how dotted keys define tables.

toml.abnf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ newline =/ %x0D.0A ; CRLF
3737

3838
;; Comment
3939

40-
comment = comment-start-symbol *allowed-comment-char
4140
comment-start-symbol = %x23 ; #
42-
allowed-comment-char = %x01-09 / %x0E-7F / non-ascii
4341
non-ascii = %x80-D7FF / %xE000-10FFFF
42+
non-eol = %x09 / %x20-7E / non-ascii
43+
44+
comment = comment-start-symbol *non-eol
4445

4546
;; Key-Value pairs
4647

toml.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ key = "value" # This is a comment at the end of a line
5757
another = "# This is not a comment"
5858
```
5959

60-
Comments may contain any Unicode code points except the following control codes
61-
that could cause problems during editing or processing: U+0000, and U+000A to
62-
U+000D.
60+
Control characters other than tab (U+0000 to U+0008, U+000A to U+001F, U+007F)
61+
are not permitted in comments.
6362

6463
## Key/Value Pair
6564

0 commit comments

Comments
 (0)