diff options
author | Matt Farina <[email protected]> | 2014-04-29 11:14:29 -0400 |
---|---|---|
committer | Matt Farina <[email protected]> | 2014-04-29 11:14:29 -0400 |
commit | 56c6eac664e7ff446b25db583947b155a94e1584 (patch) | |
tree | daf0eb5b5c10f7a3121f22a4eb89e21274555535 /src/HTML5/Parser/DOMTreeBuilder.php | |
parent | 1f2861b528ddf2e4d7306979d3620910f45bac74 (diff) | |
parent | 4401688e65b1d979705fe4e82dfdb283813f0696 (diff) |
Merge pull request #31 from miso-belica/fix-invalid-tag-names
Don't throw an exception for invalid tag names
Diffstat (limited to 'src/HTML5/Parser/DOMTreeBuilder.php')
-rw-r--r-- | src/HTML5/Parser/DOMTreeBuilder.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index b79c298..964d662 100644 --- a/src/HTML5/Parser/DOMTreeBuilder.php +++ b/src/HTML5/Parser/DOMTreeBuilder.php @@ -223,8 +223,14 @@ class DOMTreeBuilder implements EventHandler { $lname = Elements::normalizeSvgElement($lname); } + try { + $ele = $this->doc->createElement($lname); + } + catch(\DOMException $e) { + $this->parseError("Illegal tag name: <$lname>. Replaced with <invalid>."); + $ele = $this->doc->createElement('invalid'); + } - $ele = $this->doc->createElement($lname); foreach ($attributes as $aName => $aVal) { if ($this->insertMode == static::IM_IN_SVG) { |