diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/HTML5/Parser/DOMTreeBuilder.php | 8 | ||||
-rw-r--r-- | src/HTML5/Parser/Tokenizer.php | 4 |
2 files changed, 10 insertions, 2 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) { diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php index f21d30b..a78cf23 100644 --- a/src/HTML5/Parser/Tokenizer.php +++ b/src/HTML5/Parser/Tokenizer.php @@ -322,7 +322,9 @@ class Tokenizer { } // We know this is at least one char. - $name = strtolower($this->scanner->charsUntil("/> \n\f\t")); + $name = strtolower($this->scanner->charsWhile( + ":0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + )); $attributes = array(); $selfClose = FALSE; |