Fix stack overflow when whitespace appears after attribute name and before tag-closing >
This commit is contained in:
parent
7e624c0a4a
commit
aed61d84d3
|
@ -731,7 +731,7 @@ private extension Tokenizer {
|
|||
switch c {
|
||||
case "\t", "\n", "\u{000C}", " ":
|
||||
// ignore the character
|
||||
return next()
|
||||
return tokenizeBeforeAttributeName()
|
||||
case "/", ">", nil:
|
||||
reconsume(c)
|
||||
state = .afterAttributeName
|
||||
|
@ -794,13 +794,16 @@ private extension Tokenizer {
|
|||
switch nextChar() {
|
||||
case "\t", "\n", "\u{000C}", " ":
|
||||
// ignore the character
|
||||
return tokenizeAttributeName()
|
||||
return tokenizeAfterAttributeName()
|
||||
case "/":
|
||||
state = .selfClosingStartTag
|
||||
return tokenizeSelfClosingStartTag()
|
||||
case "=":
|
||||
state = .beforeAttributeValue
|
||||
return tokenizeBeforeAttributeValue()
|
||||
case ">":
|
||||
state = .data
|
||||
return takeCurrentToken()
|
||||
case nil:
|
||||
// parse error: eof-in-tag
|
||||
state = .endOfFile
|
||||
|
|
|
@ -74,6 +74,10 @@ final class TokenizerTests: XCTestCase {
|
|||
XCTAssertEqual(tokenize("🇺🇸"), [.characterSequence("\u{1F1FA}\u{1F1F8}")])
|
||||
}
|
||||
|
||||
func testWhitespaceAfterAttributeName() {
|
||||
XCTAssertEqual(tokenize("<a foo >"), [.startTag("a", selfClosing: false, attributes: [.init(name: "foo", value: "")])])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private struct PrintIterator<Inner: IteratorProtocol>: IteratorProtocol {
|
||||
|
|
Loading…
Reference in New Issue