go/src/encoding/json
Daniel Martí 11389baf2e encoding/json: revert "avoid work when unquoting strings, take 2"
This reverts golang.org/cl/190659 and golang.org/cl/226218, minus the
regression tests in the latter.

The original work happened in golang.org/cl/151157, which was reverted
in golang.org/cl/190909 due to a crash found by fuzzing.

We tried a second time in golang.org/cl/190659, which shipped with Go
1.14. A bug was found, where strings would be mangled in certain edge
cases. The fix for that was golang.org/cl/226218, which was backported
into Go 1.14.4.

Unfortunately, a second regression was just reported in #39555, which is
a similar case of strings getting mangled when decoding under certain
conditions. It would be possible to come up with another small patch to
fix that edge case, but instead, let's just revert the entire
optimization, as it has proved to do more harm than good. Moreover, it's
hard to argue or prove that there will be no more such regressions.

However, all the work wasn't for nothing. First, we learned that the way
the decoder unquotes tokenized strings isn't simple; initially, we had
wrongly assumed that each string was unquoted exactly once and in order.
Second, we have gained a number of regression tests which will be useful
to prevent the same mistakes in the future, including the test cases we
add in this CL.

Fixes #39555.

Change-Id: I66a6919c2dd6d9789232482ba6cf3814eaa70f61
Reviewed-on: https://go-review.googlesource.com/c/go/+/237838
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2020-06-15 16:10:18 +00:00
..
testdata all: zero mtimes in testdata gz files 2016-03-25 04:02:36 +00:00
bench_test.go encoding/json: improve performance of Compact 2019-10-27 16:02:29 +00:00
decode.go encoding/json: revert "avoid work when unquoting strings, take 2" 2020-06-15 16:10:18 +00:00
decode_test.go encoding/json: revert "avoid work when unquoting strings, take 2" 2020-06-15 16:10:18 +00:00
encode.go encoding/json: properly encode strings with ",string" again 2020-05-08 13:29:11 +00:00
encode_test.go encoding/json: properly encode strings with ",string" again 2020-05-08 13:29:11 +00:00
example_marshaling_test.go encoding/json: example on MarshalJSON, UnmarshalJSON 2016-11-03 20:18:52 +00:00
example_test.go encoding/json: use SetBytes in UnmarshalReuse benchmark 2019-04-05 20:54:50 +00:00
example_text_marshaling_test.go encoding/xml, encoding/json: docs and examples using custom marshalers 2018-12-12 14:18:06 +00:00
fold.go all: link to https for golang subdomains too 2015-07-12 04:42:40 +00:00
fold_test.go build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
fuzz.go encoding/json: fix format string in the Fuzz func 2019-08-18 01:16:33 +00:00
indent.go encoding/json: improve performance of Compact 2019-10-27 16:02:29 +00:00
number_test.go all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
scanner.go encoding/json: consolidate the isSpace function 2020-02-26 17:58:41 +00:00
scanner_test.go encoding/json: stop escaping U+2028 and U+2029 in Compact 2019-10-10 11:31:54 +00:00
stream.go encoding/json: add Decoder.InputOffset for offset access 2019-10-11 16:34:01 +00:00
stream_test.go encoding/json: properly encode strings with ",string" again 2020-05-08 13:29:11 +00:00
tables.go encoding/json: Use a lookup table for safe characters 2016-09-08 18:02:34 +00:00
tagkey_test.go encoding/json: explicitly document and test "-" key tag 2016-10-06 14:42:16 +00:00
tags.go all: revert "all: prefer strings.IndexByte over strings.Index" 2017-10-05 23:19:10 +00:00
tags_test.go all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00