-
Notifications
You must be signed in to change notification settings - Fork 18k
json.Parse doesn't treat \r as whitespace #272
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
Labels
Comments
Owner changed to r...@golang.org. |
Could not send for review because of a problem with the code review plugin. The patch includes the change Robert suggested and the test. It's really tiny, so I will post it here: diff -r 44699e529c44 src/pkg/json/parse.go --- a/src/pkg/json/parse.go Fri Nov 20 15:47:15 2009 -0800 +++ b/src/pkg/json/parse.go Sun Nov 22 00:37:50 2009 +0200 @@ -198,7 +198,7 @@ return c == '"' || c == '[' || c == ']' || c == ':' || c == '{' || c == '}' || c == ',' } -func white(c byte) bool { return c == ' ' || c == '\t' || c == '\n' || c == '\v' } +func white(c byte) bool { return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\v' } func skipwhite(p string, i int) int { for i < len(p) && white(p[i]) { diff -r 44699e529c44 src/pkg/json/struct_test.go --- a/src/pkg/json/struct_test.go Fri Nov 20 15:47:15 2009 -0800 +++ b/src/pkg/json/struct_test.go Sun Nov 22 00:37:50 2009 +0200 @@ -64,6 +64,17 @@ } else { t.Logf("%s = %v (good)", name, v) } +} + +const whiteSpaceEncoded = " \t{\n\"s\"\r:\"string\"\v}"; + +func TestUnmarshalWhitespace(t *testing.T) { + var m myStruct; + ok, errtok := Unmarshal(whiteSpaceEncoded, &m); + if !ok { + t.Fatalf("Unmarshal failed near %s", errtok) + } + check(t, m.S == "string", "string", m.S); } func TestUnmarshal(t *testing.T) { |
This issue was closed by revision 68d3b6e. Status changed to Fixed. Merged into issue #-. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by metaphorically:
The text was updated successfully, but these errors were encountered: