From 8696866ef2578952ff6d8fbea2d7a12372a47ea6 Mon Sep 17 00:00:00 2001 From: Rowan Tommins Date: Wed, 24 Jun 2020 13:01:34 +0100 Subject: Add special case for end tag
. Fixes #185 Normally, an end tag for a void element would simply be discarded, but the spec includes a special rule as follows: > An end tag whose tag name is "br" > Parse error. Drop the attributes from the token, and act as > described in the next entry; i.e. act as if this was a "br" > start tag token with no attributes, rather than the end tag > token that it actually is. --- src/HTML5/Parser/DOMTreeBuilder.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/HTML5/Parser') diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index e9bca4e..448dec7 100644 --- a/src/HTML5/Parser/DOMTreeBuilder.php +++ b/src/HTML5/Parser/DOMTreeBuilder.php @@ -474,8 +474,14 @@ class DOMTreeBuilder implements EventHandler { $lname = $this->normalizeTagName($name); - // Ignore closing tags for unary elements. - if (Elements::isA($name, Elements::VOID_TAG)) { + // Special case within 12.2.6.4.7: An end tag whose tag name is "br" should be treated as an opening tag + if ($name === 'br') { + $this->parseError('Closing tag encountered for void element br.'); + + $this->startTag('br'); + } + // Ignore closing tags for other unary elements. + elseif (Elements::isA($name, Elements::VOID_TAG)) { return; } -- cgit v1.2.3