Skip to content

Commit

Permalink
Merge pull request #258 from Link1515/fix/duplicate-attributes
Browse files Browse the repository at this point in the history
Ignore duplicate attributes
  • Loading branch information
goetas authored Feb 15, 2025
2 parents ab71073 + 1660321 commit b2375ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/HTML5/Parser/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ protected function attribute(&$attributes)
$this->scanner->whitespace();

$val = $this->attributeValue();
if ($isValidAttribute) {
if ($isValidAttribute && !array_key_exists($name, $attributes)) {
$attributes[$name] = $val;
}

Expand Down
8 changes: 8 additions & 0 deletions test/HTML5/Parser/TokenizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,14 @@ public function testTagAttributes()
),
false,
),
// duplicate attributes must be ignored
'<foo bar="first" bar="second">' => array(
'foo',
array(
'bar' => 'first',
),
false,
),
);
$this->isAllGood('startTag', 2, $good);

Expand Down

0 comments on commit b2375ac

Please sign in to comment.