diff options
| author | Ian Lance Taylor <iant@golang.org> | 2022-03-31 12:30:14 -0700 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2022-03-31 20:37:15 +0000 |
| commit | 31ee4bb28dff98f29654e7f1b43488641b3157db (patch) | |
| tree | 1a4945faaa521e938209d9b6ba86315718b9bbf6 /src | |
| parent | 825309962fd6d8e34f7f38f51c4994395826d139 (diff) | |
| download | go-31ee4bb28dff98f29654e7f1b43488641b3157db.tar.xz | |
strconv: quote rune 007F as \x7f, not \u007f
\u007f is not wrong but it's weird to use \u when we could use the
shorter \x.
Fixes #52062
Change-Id: Ica4bdc2463128051876f44e15297ed1e9edf1de8
Reviewed-on: https://go-review.googlesource.com/c/go/+/397255
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/strconv/quote.go | 2 | ||||
| -rw-r--r-- | src/strconv/quote_test.go | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/strconv/quote.go b/src/strconv/quote.go index 9d20b75a58..6c022846c0 100644 --- a/src/strconv/quote.go +++ b/src/strconv/quote.go @@ -99,7 +99,7 @@ func appendEscapedRune(buf []byte, r rune, quote byte, ASCIIonly, graphicOnly bo buf = append(buf, `\v`...) default: switch { - case r < ' ': + case r < ' ' || r == 0x7f: buf = append(buf, `\x`...) buf = append(buf, lowerhex[byte(r)>>4]) buf = append(buf, lowerhex[byte(r)&0xF]) diff --git a/src/strconv/quote_test.go b/src/strconv/quote_test.go index 81fc8f79e1..fc000de7b1 100644 --- a/src/strconv/quote_test.go +++ b/src/strconv/quote_test.go @@ -55,6 +55,7 @@ var quotetests = []quoteTest{ {"\x04", `"\x04"`, `"\x04"`, `"\x04"`}, // Some non-printable but graphic runes. Final column is double-quoted. {"!\u00a0!\u2000!\u3000!", `"!\u00a0!\u2000!\u3000!"`, `"!\u00a0!\u2000!\u3000!"`, "\"!\u00a0!\u2000!\u3000!\""}, + {"\x7f", `"\x7f"`, `"\x7f"`, `"\x7f"`}, } func TestQuote(t *testing.T) { |
