Skip to content

Commit

Permalink
encoding/xml: restore changes lost in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ydnar committed Sep 27, 2021
1 parent 7280904 commit c4e8c55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/encoding/xml/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/encoding/xml/xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ var characterTests = []struct {
{"<?xml version=\"1.0\"?>\x0b<doc/>", "illegal character code U+000B"},
{"\xef\xbf\xbe<doc/>", "illegal character code U+FFFE"},
{"<?xml version=\"1.0\"?><doc>\r\n<hiya/>\x07<toots/></doc>", "illegal character code U+0007"},
{"<?xml version=\"1.0\"?><doc \x12='value'>what's up</doc>", "expected = after attribute name"},
{"<?xml version=\"1.0\"?><doc \x12='value'>what's up</doc>", "expected attribute name in element"},
{"<doc>&abc\x01;</doc>", "invalid character entity &abc (no semicolon)"},
{"<doc>&\x01;</doc>", "invalid character entity & (no semicolon)"},
{"<doc>&\xef\xbf\xbe;</doc>", "invalid character entity &\uFFFE;"},
Expand Down

0 comments on commit c4e8c55

Please sign in to comment.