From 903a227b9b99d04ae84564cc07f246cbc8e175a5 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Thu, 14 Jun 2018 15:07:04 -0400 Subject: [PATCH] godoc/static: mimic the pre-1.10 behavior of strconv.Quote Thanks to iant for identifying the root cause. Tested with go1.9 and go1.10. Fixes golang/go#25880 Change-Id: Ibc3a2aadd92c1e512cf6c537134ee085398e8e6c Reviewed-on: https://go-review.googlesource.com/118955 Reviewed-by: Brad Fitzpatrick --- godoc/static/gen.go | 10 +++++++++- godoc/static/gen_test.go | 2 -- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/godoc/static/gen.go b/godoc/static/gen.go index 5ffa6d0c..b622e783 100644 --- a/godoc/static/gen.go +++ b/godoc/static/gen.go @@ -88,7 +88,15 @@ func Generate() ([]byte, error) { fmt.Fprintf(buf, ",\n\n") } fmt.Fprintln(buf, "}") - return format.Source(buf.Bytes()) + + b := buf.Bytes() + + // The ιΏ₯ U+9FE5 character became printable in go 1.10, + // causing it to appear literally in newer output. + // Force the old behavior. + b = bytes.Replace(b, []byte("\u9fe5"), []byte(`\u9fe5`), -1) + + return format.Source(b) } // sanitize prepares a valid UTF-8 string as a raw string constant. diff --git a/godoc/static/gen_test.go b/godoc/static/gen_test.go index 95e9bfc5..477a714e 100644 --- a/godoc/static/gen_test.go +++ b/godoc/static/gen_test.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//+build go1.10 - package static import (