aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/xml.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2024-03-08 18:25:14 +0000
committerGopher Robot <gobot@golang.org>2024-03-08 18:46:41 +0000
commit32014d549609422748dcb698fef1d43a5a33b0b4 (patch)
tree163cd85fd56ff2d701291d314eedb4e327a0d185 /src/encoding/xml/xml.go
parenta46285f8c2389b92952c1484daacfccf70a17047 (diff)
downloadgo-32014d549609422748dcb698fef1d43a5a33b0b4.tar.xz
Revert "encoding/xml: reject XML declaration after start of document"
This reverts commit 8a0fbd75a54c27ff2ae624ac2775bf752cdbceb4. Reason for revert: Breaking real-world tests inside Google, which means it probably breaks real-world tests outside Google. One instance I have seen is a <!-- --> comment (often a copyright notice) before the procinst. Another test checks that a canonicalizer can handle a test input that simply has procinsts mid-XML. XML is full of contradictions, XML implementations more so. If we are going to start being picky, that probably needs to be controlled by a GODEBUG (and a proposal). For #65691 (will reopen manually). Change-Id: Ib52d0944b1478e71744a2a35b271fdf7e1c972ca Reviewed-on: https://go-review.googlesource.com/c/go/+/570175 Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/encoding/xml/xml.go')
-rw-r--r--src/encoding/xml/xml.go12
1 files changed, 0 insertions, 12 deletions
diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
index 582cfee222..0fe323f7c8 100644
--- a/src/encoding/xml/xml.go
+++ b/src/encoding/xml/xml.go
@@ -212,7 +212,6 @@ type Decoder struct {
line int
linestart int64
offset int64
- readNonWS bool
unmarshalDepth int
}
@@ -564,8 +563,6 @@ func (d *Decoder) rawToken() (Token, error) {
return EndElement{d.toClose}, nil
}
- readNonWS := d.readNonWS
-
b, ok := d.getc()
if !ok {
return nil, d.err
@@ -578,12 +575,8 @@ func (d *Decoder) rawToken() (Token, error) {
if data == nil {
return nil, d.err
}
- if !d.readNonWS && !isWhitespace(CharData(data)) {
- d.readNonWS = true
- }
return CharData(data), nil
}
- d.readNonWS = true
if b, ok = d.mustgetc(); !ok {
return nil, d.err
@@ -634,11 +627,6 @@ func (d *Decoder) rawToken() (Token, error) {
data = data[0 : len(data)-2] // chop ?>
if target == "xml" {
- if readNonWS {
- d.err = errors.New("xml: XML declaration after start of document")
- return nil, d.err
- }
-
content := string(data)
ver := procInst("version", content)
if ver != "" && ver != "1.0" {