]> Cypherpunks repositories - gostls13.git/commitdiff
strconv: quote rune 007F as \x7f, not \u007f
authorIan Lance Taylor <iant@golang.org>
Thu, 31 Mar 2022 19:30:14 +0000 (12:30 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 31 Mar 2022 20:37:15 +0000 (20:37 +0000)
\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>
api/go1.1.txt
doc/go1.19.html
src/strconv/quote.go
src/strconv/quote_test.go

index bb00b3b02cc8ad8fffcd32f4df04df67c30cbce8..06291faa4b25050152a6ccf8112418233c7842b7 100644 (file)
@@ -371,7 +371,7 @@ pkg debug/elf, const ELFCLASSNONE = 0
 pkg debug/elf, const ELFDATA2LSB = 1
 pkg debug/elf, const ELFDATA2MSB = 2
 pkg debug/elf, const ELFDATANONE = 0
-pkg debug/elf, const ELFMAG = "\u007fELF"
+pkg debug/elf, const ELFMAG = "\x7fELF"
 pkg debug/elf, const ELFOSABI_86OPEN = 5
 pkg debug/elf, const ELFOSABI_AIX = 7
 pkg debug/elf, const ELFOSABI_ARM = 97
index c0e2cf1761f00c60f7d55aea24d2a3e589e39f50..cfeb3d3d79417ae3415be569e8c7a02cead2314c 100644 (file)
@@ -90,4 +90,14 @@ Do not send CLs removing the interior tags from such phrases.
       issue tracker</a>.
     </p>
   </dd>
-</dl>
+</dl><!-- net -->
+
+<dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt>
+  <dd>
+    <p><!-- CL 397255 -->
+      <a href="/pkg/strconv/#strconv.Quote"><code>strconv.Quote</code></a>
+      and related functions now quote the rune 007F as <code>\x7f</code>,
+      not <code>\u007f</code>.
+    </p>
+  </dd>
+</dl><!-- strconv -->
index 9d20b75a58afb94d14a376a7a28c20177c287e21..6c022846c0812c232a43d8c99219120ff469cacb 100644 (file)
@@ -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])
index 81fc8f79e147499f14798d1831bb8d61d6b55ce2..fc000de7b17f1d5b80ba0a09e7b3af1a8aa77d14 100644 (file)
@@ -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) {