Skip to content

Commit c4e8c55

Browse files
committed
encoding/xml: restore changes lost in merge
See golang#43168.
1 parent 7280904 commit c4e8c55

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/encoding/xml/xml.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,15 @@ func (d *Decoder) rawToken() (Token, error) {
835835
d.ungetc(b)
836836

837837
a := Attr{}
838-
// Tag has a list of attributes bound to a namespace or not.
839-
a.Name, ok = d.nsname()
840-
// if !ok the attribute name has no namespace
838+
if a.Name, ok = d.nsname(); !ok {
839+
if d.err == nil {
840+
d.err = d.syntaxError("expected attribute name in element")
841+
}
842+
return nil, d.err
843+
}
841844
d.space()
842845
if b, ok = d.mustgetc(); !ok {
843-
d.err = d.syntaxError("expected attribute name in element")
846+
// d.err = d.syntaxError("expected attribute name in element")
844847
return nil, d.err
845848
}
846849
if b != '=' { // nsname.Local is the attribute name if xmlns is present otherwise err was returned

src/encoding/xml/xml_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ var characterTests = []struct {
730730
{"<?xml version=\"1.0\"?>\x0b<doc/>", "illegal character code U+000B"},
731731
{"\xef\xbf\xbe<doc/>", "illegal character code U+FFFE"},
732732
{"<?xml version=\"1.0\"?><doc>\r\n<hiya/>\x07<toots/></doc>", "illegal character code U+0007"},
733-
{"<?xml version=\"1.0\"?><doc \x12='value'>what's up</doc>", "expected = after attribute name"},
733+
{"<?xml version=\"1.0\"?><doc \x12='value'>what's up</doc>", "expected attribute name in element"},
734734
{"<doc>&abc\x01;</doc>", "invalid character entity &abc (no semicolon)"},
735735
{"<doc>&\x01;</doc>", "invalid character entity & (no semicolon)"},
736736
{"<doc>&\xef\xbf\xbe;</doc>", "invalid character entity &\uFFFE;"},

0 commit comments

Comments
 (0)