diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go index 9ae0a5e8987fb..462a99f83bfc5 100644 --- a/src/encoding/xml/xml.go +++ b/src/encoding/xml/xml.go @@ -835,12 +835,15 @@ func (d *Decoder) rawToken() (Token, error) { d.ungetc(b) a := Attr{} - // Tag has a list of attributes bound to a namespace or not. - a.Name, ok = d.nsname() - // if !ok the attribute name has no namespace + if a.Name, ok = d.nsname(); !ok { + if d.err == nil { + d.err = d.syntaxError("expected attribute name in element") + } + return nil, d.err + } d.space() if b, ok = d.mustgetc(); !ok { - d.err = d.syntaxError("expected attribute name in element") + // d.err = d.syntaxError("expected attribute name in element") return nil, d.err } if b != '=' { // nsname.Local is the attribute name if xmlns is present otherwise err was returned diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go index 2608f35c2dcfc..e50a0547a2873 100644 --- a/src/encoding/xml/xml_test.go +++ b/src/encoding/xml/xml_test.go @@ -730,7 +730,7 @@ var characterTests = []struct { {"\x0b", "illegal character code U+000B"}, {"\xef\xbf\xbe", "illegal character code U+FFFE"}, {"\r\n\x07", "illegal character code U+0007"}, - {"what's up", "expected = after attribute name"}, + {"what's up", "expected attribute name in element"}, {"&abc\x01;", "invalid character entity &abc (no semicolon)"}, {"&\x01;", "invalid character entity & (no semicolon)"}, {"&\xef\xbf\xbe;", "invalid character entity &\uFFFE;"},