diff --git a/src/pkg/exp/html/escape.go b/src/pkg/exp/html/escape.go index c177a66068..6a9d8f6e6f 100644 --- a/src/pkg/exp/html/escape.go +++ b/src/pkg/exp/html/escape.go @@ -192,7 +192,7 @@ func lower(b []byte) []byte { return b } -const escapedChars = `&'<>"` +const escapedChars = "&'<>\"\r" func escape(w writer, s string) error { i := strings.IndexAny(s, escapedChars) @@ -214,6 +214,8 @@ func escape(w writer, s string) error { case '"': // """ is shorter than """. esc = """ + case '\r': + esc = " " default: panic("unrecognized escape character") } diff --git a/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log b/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log index acf1780cf2..1d8aee8423 100644 --- a/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log +++ b/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log @@ -21,8 +21,8 @@ PASS "\x00
\r\n\r\nA
\r\rA
\rA