b.Write(s[written:cs])
written = i1
}
+ if i == i1 && c.state == c1.state {
+ panic(fmt.Sprintf("infinite loop from %v to %v on %q..%q", c, c1, s[:i], s[i:]))
+ }
c, i = c1, i1
}
`<a style=font:'Arial'>`,
`exp/template/html:z: "'" in unquoted attr: "font:'Arial'"`,
},
+ {
+ `<a=foo>`,
+ `: expected space, attr name, or end of tag, but got "=foo>"`,
+ },
}
for _, test := range tests {
return context{state: stateError, err: err}, len(s)
}
state, attr := stateTag, attrNone
- if i != j {
- canonAttrName := strings.ToLower(string(s[i:j]))
- switch attrType[canonAttrName] {
- case contentTypeURL:
- attr = attrURL
- case contentTypeCSS:
- attr = attrStyle
- case contentTypeJS:
+ if i == j {
+ return context{
+ state: stateError,
+ err: errorf(ErrBadHTML, 0, "expected space, attr name, or end of tag, but got %q", s[i:]),
+ }, len(s)
+ }
+ canonAttrName := strings.ToLower(string(s[i:j]))
+ switch attrType[canonAttrName] {
+ case contentTypeURL:
+ attr = attrURL
+ case contentTypeCSS:
+ attr = attrStyle
+ case contentTypeJS:
+ attr = attrScript
+ default:
+ if strings.HasPrefix(canonAttrName, "on") {
attr = attrScript
- default:
- if strings.HasPrefix(canonAttrName, "on") {
- attr = attrScript
- }
- }
- if j == len(s) {
- state = stateAttrName
- } else {
- state = stateAfterName
}
}
+ if j == len(s) {
+ state = stateAttrName
+ } else {
+ state = stateAfterName
+ }
return context{state: state, element: c.element, attr: attr}, j
}