aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/xml.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/xml/xml.go')
-rw-r--r--src/encoding/xml/xml.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
index 0c64cd730d..00792c4f27 100644
--- a/src/encoding/xml/xml.go
+++ b/src/encoding/xml/xml.go
@@ -1863,6 +1863,13 @@ var (
// EscapeText writes to w the properly escaped XML equivalent
// of the plain text data s.
func EscapeText(w io.Writer, s []byte) error {
+ return escapeText(w, s, true)
+}
+
+// escapeText writes to w the properly escaped XML equivalent
+// of the plain text data s. If escapeNewline is true, newline
+// characters will be escaped.
+func escapeText(w io.Writer, s []byte, escapeNewline bool) error {
var esc []byte
last := 0
for i := 0; i < len(s); {
@@ -1882,6 +1889,9 @@ func EscapeText(w io.Writer, s []byte) error {
case '\t':
esc = esc_tab
case '\n':
+ if !escapeNewline {
+ continue
+ }
esc = esc_nl
case '\r':
esc = esc_cr