Skip to content

Commit b2375ac

Browse files
authored
Merge pull request #258 from Link1515/fix/duplicate-attributes
Ignore duplicate attributes
2 parents ab71073 + 1660321 commit b2375ac

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/HTML5/Parser/Tokenizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ protected function attribute(&$attributes)
507507
$this->scanner->whitespace();
508508

509509
$val = $this->attributeValue();
510-
if ($isValidAttribute) {
510+
if ($isValidAttribute && !array_key_exists($name, $attributes)) {
511511
$attributes[$name] = $val;
512512
}
513513

test/HTML5/Parser/TokenizerTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,14 @@ public function testTagAttributes()
705705
),
706706
false,
707707
),
708+
// duplicate attributes must be ignored
709+
'<foo bar="first" bar="second">' => array(
710+
'foo',
711+
array(
712+
'bar' => 'first',
713+
),
714+
false,
715+
),
708716
);
709717
$this->isAllGood('startTag', 2, $good);
710718

0 commit comments

Comments
 (0)