From f9a9b7012397ec4c4a18f49352d919266816dbd7 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Fri, 14 Sep 2012 05:30:21 +0200 Subject: [PATCH] Detect the namespace uri from token name --- library/HTML5/TreeBuilder.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/library/HTML5/TreeBuilder.php b/library/HTML5/TreeBuilder.php index 578e73682..26cd410bf 100644 --- a/library/HTML5/TreeBuilder.php +++ b/library/HTML5/TreeBuilder.php @@ -3037,8 +3037,22 @@ class HTML5_TreeBuilder { } private function insertElement($token, $append = true) { - $el = $this->dom->createElementNS(self::NS_HTML, $token['name']); - + $sep_pos = strpos($token['name'],':'); + $ns_uri = self::NS_HTML; + if($sep_pos !== FALSE) { + // This tag has a namespace + $ns = substr($token['name'], 0, $sep_pos); + switch($ns) { + case 'g': + $ns_uri = 'http://base.google.com/ns/1.0'; + break; + default: + logger("HTML5/TreeBuilder.php: Unknown namespace '". $ns ."', tag = ". $token['name'], LOGGER_DEBUG); + break; + } + } + $el = $this->dom->createElementNS($ns_uri, $token['name']); + if (!empty($token['attr'])) { foreach($token['attr'] as $attr) {