go/src/strconv
Joe Tsai 6e50991d2a strconv: reject surrogate halves in Unquote
Unquote implements unescaping a "single-quoted, doubled-quoted, or
backquoted Go string literal". Therefore, it should reject anything
that the Go specification explicitly forbids.

The section on "Rune literals" explicitly rejects rune values
"above 0x10FFFF and surrogate halves". We properly checked for
the previous condition, but were failing to check for the latter.

In general, "r > utf8.MaxRune" is probably the wrong check,
while !utf8.ValidRune(r) is the more correct check.
We make changes to both UnquoteChar and appendEscapedRune
to use the correct check. The change to appendEscapedRune
is technically a noop since callers of that function already
guarantee that the provided rune is valid.

Fixes #47853

Change-Id: Ib8977e56b91943ec8ada821b8d217b5e9a66f950
Reviewed-on: https://go-review.googlesource.com/c/go/+/343877
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2021-08-21 18:23:58 +00:00
..
testdata
atob.go
atob_test.go
atoc.go strconv: revert ParseFloat/ParseComplex error on incorrect bitSize 2020-11-03 23:05:51 +00:00
atoc_test.go strconv: revert ParseFloat/ParseComplex error on incorrect bitSize 2020-11-03 23:05:51 +00:00
atof.go strconv: ParseFloat: always return ErrSyntax for bad syntax 2021-06-07 21:12:46 +00:00
atof_test.go strconv: ParseFloat: always return ErrSyntax for bad syntax 2021-06-07 21:12:46 +00:00
atoi.go strconv: document parsing of leading +/- 2021-06-09 18:16:27 +00:00
atoi_test.go strconv: document parsing of leading +/- 2021-06-09 18:16:27 +00:00
bytealg.go strconv: add QuotedPrefix 2021-05-04 00:56:00 +00:00
bytealg_bootstrap.go strconv: add QuotedPrefix 2021-05-04 00:56:00 +00:00
ctoa.go strconv: add ParseComplex and FormatComplex 2020-05-08 17:31:38 +00:00
ctoa_test.go strconv: fix incorrect bit size in ParseComplex; add tests 2020-10-30 00:13:25 +00:00
decimal.go
decimal_test.go
doc.go
eisel_lemire.go [dev.regabi] strconv: add to bootstrap packages 2020-11-24 19:42:42 +00:00
example_test.go
export_test.go
fp_test.go
ftoa.go strconv: Implement Ryū algorithm for ftoa shortest mode 2021-04-15 09:18:03 +00:00
ftoa_test.go strconv: Implement Ryū algorithm for ftoa shortest mode 2021-04-15 09:18:03 +00:00
ftoaryu.go all: fix typos 2021-08-17 13:54:10 +00:00
ftoaryu_test.go strconv: implement Ryū-like algorithm for fixed precision ftoa 2021-04-15 08:44:21 +00:00
internal_test.go strconv: implement Ryū-like algorithm for fixed precision ftoa 2021-04-15 08:44:21 +00:00
isprint.go unicode: upgrade to Unicode 13.0.0 2020-08-20 13:41:13 +00:00
itoa.go
itoa_test.go
makeisprint.go all: faster midpoint computation in binary search 2021-02-23 01:37:31 +00:00
quote.go strconv: reject surrogate halves in Unquote 2021-08-21 18:23:58 +00:00
quote_test.go strconv: reject surrogate halves in Unquote 2021-08-21 18:23:58 +00:00
strconv_test.go