mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
xml: allow unquoted attribute values in non-Strict mode
HTML4 standard supports unquoted attibute values in certain cases (http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.2). R=rsc CC=golang-dev https://golang.org/cl/207095
This commit is contained in:
parent
00d29db3a9
commit
d8675d25e5
2 changed files with 55 additions and 8 deletions
|
|
@ -298,3 +298,23 @@ func TestIssue569(t *testing.T) {
|
|||
t.Fatalf("Expecting abcd")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnquotedAttrs(t *testing.T) {
|
||||
data := "<tag attr=azAZ09:-_\t>"
|
||||
p := NewParser(StringReader(data))
|
||||
p.Strict = false
|
||||
token, err := p.Token()
|
||||
if _, ok := err.(SyntaxError); ok {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
if token.(StartElement).Name.Local != "tag" {
|
||||
t.Errorf("Unexpected tag name: %v", token.(StartElement).Name.Local)
|
||||
}
|
||||
attr := token.(StartElement).Attr[0]
|
||||
if attr.Value != "azAZ09:-_" {
|
||||
t.Errorf("Unexpected attribute value: %v", attr.Value)
|
||||
}
|
||||
if attr.Name.Local != "attr" {
|
||||
t.Errorf("Unexpected attribute name: %v", attr.Name.Local)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue