Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
Fix a tokenizer bug causing incorrect handling of duplicate attributes
Browse files Browse the repository at this point in the history
The tag buffer was retaining duplicate attribute values that were marked
to be discarded, thus clobbering the following attribute name.

This also fixes the relevant test, which didn't catch this particular
case because it had an empty (boolean-style) value as the duplicate.
  • Loading branch information
craigbarnes committed Nov 27, 2013
1 parent d90ea2b commit 3068711
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ static void finish_attribute_value(GumboParser* parser) {
// Duplicate attribute name detected in an earlier state, so we have to
// ignore the value.
tag_state->_drop_next_attr_value = false;
reinitialize_tag_buffer(parser);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ TEST_F(GumboParserTest, Whitespace) {
}

TEST_F(GumboParserTest, DuplicateAttributes) {
std::string text("<input checked=\"false\" checked id=foo id='bar'>");
std::string text("<input checked=\"false\" checked=true id=foo id='bar'>");
Parse(text);

GumboNode* body;
Expand Down

0 comments on commit 3068711

Please sign in to comment.