From 77f4a36d9095dbdf08e5a8a58f2d5be0740dfe6c Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Sun, 3 Mar 2013 21:41:27 +0100 Subject: [PATCH] Ignore invalid tokens when scraping an URL --- library/HTML5/TreeBuilder.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/HTML5/TreeBuilder.php b/library/HTML5/TreeBuilder.php index 2a789f4df9..cdea5373f3 100644 --- a/library/HTML5/TreeBuilder.php +++ b/library/HTML5/TreeBuilder.php @@ -3039,7 +3039,11 @@ class HTML5_TreeBuilder { } private function insertElement($token, $append = true) { - $el = $this->dom->createElementNS(self::NS_HTML, $token['name']); + $el = $this->dom->createElementNS(self::NS_HTML, $token['name']); + if ($el == false) { + logger('insertElement(): ignoring invalid token='.$token['name']); + return false; + } if (!empty($token['attr'])) { foreach($token['attr'] as $attr) { -- 2.39.5