Compare commits

..

No commits in common. "bbf40bb0e4f47860677c7115b2eaa5b3413ce23e" and "6ee9f877d683381343bc998c137339c7ae908b86" have entirely different histories.

2 changed files with 7 additions and 16 deletions

View File

@ -1926,10 +1926,6 @@ func AppendJSONString(dst []byte, s string) []byte {
if s[i] < ' ' { if s[i] < ' ' {
dst = append(dst, '\\') dst = append(dst, '\\')
switch s[i] { switch s[i] {
case '\b':
dst = append(dst, 'b')
case '\f':
dst = append(dst, 'f')
case '\n': case '\n':
dst = append(dst, 'n') dst = append(dst, 'n')
case '\r': case '\r':

View File

@ -2578,19 +2578,14 @@ func TestJSONString(t *testing.T) {
testJSONString(t, s) testJSONString(t, s)
testJSONString(t, "R\xfd\xfc\a!\x82eO\x16?_\x0f\x9ab\x1dr") testJSONString(t, "R\xfd\xfc\a!\x82eO\x16?_\x0f\x9ab\x1dr")
testJSONString(t, "_\xb9\v\xad\xb3|X!\xb6\xd9U&\xa4\x1a\x95\x04") testJSONString(t, "_\xb9\v\xad\xb3|X!\xb6\xd9U&\xa4\x1a\x95\x04")
data, _ := json.Marshal("\b\f") rng := rand.New(rand.NewSource(time.Now().UnixNano()))
if (string(data) == "\"\\b\\f\"") { start := time.Now()
// Go version 1.22+ encodes "\b" and "\f" correctly. var buf [16]byte
testJSONString(t, "\b\f") for time.Since(start) < time.Second*2 {
rng := rand.New(rand.NewSource(time.Now().UnixNano())) if _, err := rng.Read(buf[:]); err != nil {
start := time.Now() t.Fatal(err)
var buf [16]byte
for time.Since(start) < time.Second*2 {
if _, err := rng.Read(buf[:]); err != nil {
t.Fatal(err)
}
testJSONString(t, string(buf[:]))
} }
testJSONString(t, string(buf[:]))
} }
} }