|
|
|
Created:
16 years, 1 month ago by skibaa Modified:
2 years, 2 months ago Reviewers:
CC:
rsc, golang-dev Visibility:
Public. |
Handle \r as a whitespace when parsing JSON string.
Fixes issue 272.
Patch Set 1 #Patch Set 2 : code review 161061: Handle \r as a whitespace when parsing JSON string. #
Total messages: 5
|
skibaa
Hello rsc, I'd like you to review the following change.
|
16 years, 1 month ago (2009年11月26日 18:26:46 UTC) #1 | ||||||||||||||||||||||
Hello rsc, I'd like you to review the following change.
thanks. could you please fill out the CLA as described at http://golang.org/doc/contribute.html#copyright and let me know once you have? there is no need to send a separate AUTHORS/CONTRIBUTORS CL - we'll take care of that - just let me know when you've completed the appropriate contributor agreement. thanks. russ On Thu, Nov 26, 2009 at 10:26, <skibaa@gmail.com> wrote: > Reviewers: rsc, > > Message: > Hello rsc, > > I'd like you to review the following change. > > > Description: > Handle \r as a whitespace when parsing JSON string. > Fixes issue 272. > > Please review this at http://codereview.appspot.com/161061 > > Affected files: > M src/pkg/json/parse.go > M src/pkg/json/struct_test.go > > > Index: src/pkg/json/parse.go > =================================================================== > --- a/src/pkg/json/parse.go > +++ b/src/pkg/json/parse.go > @@ -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]) { > Index: src/pkg/json/struct_test.go > =================================================================== > --- a/src/pkg/json/struct_test.go > +++ b/src/pkg/json/struct_test.go > @@ -66,6 +66,17 @@ > } > } > > +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) { > var m myStruct; > m.F = true; > > >
*** Submitted as http://code.google.com/p/go/source/detail?r=f7ba88b06ce9 *** Handle \r as a whitespace when parsing JSON string. Fixes issue 272. R=rsc http://codereview.appspot.com/161061 Committer: Russ Cox <rsc@golang.org>