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

Fix string fields w/ trailing slashes #7679

Merged
merged 1 commit into from
Dec 5, 2016
Merged

Fix string fields w/ trailing slashes #7679

merged 1 commit into from
Dec 5, 2016

Conversation

jwilder
Copy link
Contributor

@jwilder jwilder commented Dec 1, 2016

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

A string field w/ a trailing slash before the quote would parse incorrectly
because the quote would be seen as escaped. We have to treat \ as an
escape sequence within strings in order to handle this.

@e-dard

A string field w/ a trailing slash before the quote would parse incorrectly
because the quote would be seen as escaped.  We have to treat \\ as an
escape sequence within strings in order to handle this.
// Only escape char for a field value is a double-quote
if buf[i] == '\\' && i+1 < len(buf) && buf[i+1] == '"' {
// Only escape char for a field value is a double-quote and backslash
if buf[i] == '\\' && i+1 < len(buf) && (buf[i+1] == '"' || buf[i+1] == '\\') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From recollection of when I did the er-escape-backslash branch, I don't think this quite captures the desirable behaviour.

If the rule is "the only escapable characters are a double quote and a backslash" then what happens if we hit a backslash that isn't followed by a double quote or a backslash. For example:

cpu value="foo\s"

This current approach I think will skip over the single slash silently, but I feel like maybe it should be an error? Possibly we have discussed this before..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It think it should skip over the single \. If it returns an error, that's going to break existing clients.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, in that case LGTM 👍

@jwilder jwilder merged commit 1677aff into master Dec 5, 2016
@jwilder jwilder deleted the jw-line-slash branch December 5, 2016 17:17
@jwilder jwilder added this to the 1.1.1 milestone Dec 6, 2016
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.

None yet

2 participants