Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(53)

Issue 11211045: code review 11211045: encoding/json: coerce invalid UTF-8 to valid UTF-8 duri... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 10 months ago by rsc
Modified:
11 years, 10 months ago
Reviewers:
r, crawshaw1
CC:
golang-dev, crawshaw1
Visibility:
Public.

Description

encoding/json: coerce invalid UTF-8 to valid UTF-8 during Marshal In practice, rejecting an entire structure due to a single invalid byte in a string is just too picky, and too hard to track down. Be consistent with the bulk of the standard library by converting invalid UTF-8 into UTF-8 with replacement runes.

Patch Set 1 #

Patch Set 2 : diff -r d7a46e096cf0 https://code.google.com/p/go/ #

Patch Set 3 : diff -r d7a46e096cf0 https://code.google.com/p/go/ #

Total comments: 1

Patch Set 4 : diff -r 479890e74f24 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -11 lines) Patch
M doc/go1.2.txt View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/encoding/json/decode_test.go View 1 2 1 chunk +3 lines, -8 lines 0 comments Download
M src/pkg/encoding/json/encode.go View 1 2 chunks +13 lines, -3 lines 0 comments Download

Messages

Total messages: 4
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
11 years, 10 months ago (2013-07-12 18:39:10 UTC) #1
crawshaw1
LGTM
11 years, 10 months ago (2013-07-12 21:28:52 UTC) #2
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=f6ae6596a571 *** encoding/json: coerce invalid UTF-8 to valid UTF-8 during Marshal In ...
11 years, 10 months ago (2013-07-12 21:37:14 UTC) #3
r
11 years, 10 months ago (2013-07-12 21:38:09 UTC) #4
Message was sent while issue was closed.
LGTM

https://codereview.appspot.com/11211045/diff/6001/src/pkg/encoding/json/decod...
File src/pkg/encoding/json/decode_test.go (right):

https://codereview.appspot.com/11211045/diff/6001/src/pkg/encoding/json/decod...
src/pkg/encoding/json/decode_test.go:395: s := "hello\xffworld"
this is a pretty weak test case but the code is easy enough it's probably ok.
if you're in the mood, make it a table with at least

{"",""}
{"\xff", "\uffd"}
{"\xff\xff", "\uffd\uffd"}
{"a\xffb", "a\uffdb"}
{"\xe6\x97\xa5\xe6\x9c\xac\xff\xaa\x9e", "日本\uffd\uffd\uffd"}
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b