Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification about newlines in multi-line strings and empty keys in quotes #286

Closed
wants to merge 2 commits into from

Conversation

alexcrichton
Copy link
Contributor

I updated some of the language around multi-line basic strings to be clear that they allow bare newlines (I think this is ok, right?).

I also didn't see specific discussion of an empty key in quotes after #283, so I added a commit as well which uses them as an example of bad key names. I could revert this, however, if it's not desired!

The spec previously sounded like it required newlines to be escaped (as they're
a control character), but it looks like this may have been by accident.
@ChristianSi
Copy link
Contributor

I don't really get the point of the first commit: newlines are Unicode character just like any other, so of course they are allowed. Also, the name "multi-line strings" already implies that they can contain newlines.

As for the second commit, I'd think that any string within quotation marks is valid, including the empty string. Certainly not a good idea to use that as part of a key but I don't see a reason why it should be illegal.

@mojombo
Copy link
Member

mojombo commented Jan 16, 2015

@alexcrichton I'm not sure this change is necessary. I agree with @ChristianSi that "Any Unicode character may be used except those that must be escaped" is quite clear about what's allowed.

As for empty quoted keys, I don't think they should be allowed. I can't think of a single good reason a config file would need a blank key, and allowing them could lead to accidentally incorrect parser behavior and confused consumers of config files. The ABNF I'm working on already disallows it:

key = unquoted-key / quoted-key
unquoted-key = 1*( ALPHA / DIGIT / %x2D / %x5F ) ; A-Z / a-z / 0-9 / - / _
quoted-key = quotation-mark 1*basic-char quotation-mark ; See Basic Strings

I'm planning on including the ABNF in the actual spec soon, and that should be sufficient to clarify this case without requiring additional examples. How's that sound?

@alexcrichton
Copy link
Contributor Author

Hm, it appears my late-night self isn't parsing that sentence as easily as my early-morning self. I agree with @ChristianSi as well about the first change.

Also, an ABNF sounds fantastic, so I'll just close this in favor of that, thanks @mojombo!

@alexcrichton alexcrichton deleted the clarifications branch January 16, 2015 17:51
@mojombo
Copy link
Member

mojombo commented Jan 16, 2015

@alexcrichton Cool. Feel free to check out the full proposed ABNF in #236.

@ChristianSi
Copy link
Contributor

I'm not so sure it was a good idea to close this. If empty quoted keys are forbidden, then the following sentence in the spec is wrong:

Quoted keys follow the exact same rules as basic strings and allow you to use a much broader set of key names.

Since "" is certainly a valid basic string, isn't it?

I'd propose to change to sentence to something like:

Quoted keys follow the same rules as basic strings, except that the empty string ("") is forbidden. They allow you to use a much broader set of key names.

Otherwise there would be a contraction between the ABNF and the written spec which would be a bad thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants