aboutsummaryrefslogtreecommitdiff
path: root/src/time/time_test.go
diff options
context:
space:
mode:
authorAndy Pan <panjf2000@gmail.com>2021-06-23 12:59:48 +0800
committerEmmanuel Odeke <emmanuel@orijtech.com>2021-06-24 03:20:33 +0000
commit86d72fa2cba51342ba5617abf43a732f9fd668ca (patch)
tree162035b048cc8c1b60cc8bfa6a894d8cc337a642 /src/time/time_test.go
parent44a12e5f33bed2189735d8466b38fe455fe9b752 (diff)
downloadgo-86d72fa2cba51342ba5617abf43a732f9fd668ca.tar.gz
go-86d72fa2cba51342ba5617abf43a732f9fd668ca.zip
time: handle invalid UTF-8 byte sequences in quote to prevent panic
Fixes #46883 Updates CL 267017 Change-Id: I15c307bfb0aaa2877a148d32527681f79df1a650 Reviewed-on: https://go-review.googlesource.com/c/go/+/330289 Reviewed-by: Kevin Burke <kev@inburke.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Diffstat (limited to 'src/time/time_test.go')
-rw-r--r--src/time/time_test.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/time/time_test.go b/src/time/time_test.go
index f272bbd558..cea5f2d3f5 100644
--- a/src/time/time_test.go
+++ b/src/time/time_test.go
@@ -917,6 +917,11 @@ var parseDurationErrorTests = []struct {
{".s", `".s"`},
{"+.s", `"+.s"`},
{"1d", `"1d"`},
+ {"\x85\x85", `"\x85\x85"`},
+ {"\xffff", `"\xffff"`},
+ {"hello \xffff world", `"hello \xffff world"`},
+ {"\uFFFD", `"\xef\xbf\xbd"`}, // utf8.RuneError
+ {"\uFFFD hello \uFFFD world", `"\xef\xbf\xbd hello \xef\xbf\xbd world"`}, // utf8.RuneError
// overflow
{"9223372036854775810ns", `"9223372036854775810ns"`},
{"9223372036854775808ns", `"9223372036854775808ns"`},