diff options
author | Klaus Weidenbach <Klaus.Weidenbach@gmx.net> | 2018-03-18 02:13:05 +0100 |
---|---|---|
committer | Klaus Weidenbach <Klaus.Weidenbach@gmx.net> | 2018-03-18 02:15:29 +0100 |
commit | c80837a9e6a1d5049a03fbb608b2b650c1b0f92d (patch) | |
tree | 360fb2685c74cdac0e714a44c813dbc8efe92028 /vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer | |
parent | 0009f7f05133a74bbe3206a5b4d0223ba9dea4bc (diff) | |
download | volse-hubzilla-c80837a9e6a1d5049a03fbb608b2b650c1b0f92d.tar.gz volse-hubzilla-c80837a9e6a1d5049a03fbb608b2b650c1b0f92d.tar.bz2 volse-hubzilla-c80837a9e6a1d5049a03fbb608b2b650c1b0f92d.zip |
:arrow_up: Update libraries.
michelf/php-markdown (1.7.0 => 1.8.0)
ezyang/htmlpurifier (v4.9.3 => v4.10.0)
commerceguys/intl (v0.7.4 => v0.7.5)
sabre/http (4.2.3 => v4.2.4)
sabre/vobject (4.1.3 => 4.1.5)
Diffstat (limited to 'vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer')
-rw-r--r-- | vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php | 57 | ||||
-rw-r--r-- | vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php | 4 |
2 files changed, 49 insertions, 12 deletions
diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php index 22ab5820c..6238a99e3 100644 --- a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php @@ -127,6 +127,41 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer } /** + * Portably retrieve the tag name of a node; deals with older versions + * of libxml like 2.7.6 + * @param DOMNode $node + */ + protected function getTagName($node) + { + if (property_exists($node, 'tagName')) { + return $node->tagName; + } else if (property_exists($node, 'nodeName')) { + return $node->nodeName; + } else if (property_exists($node, 'localName')) { + return $node->localName; + } + return null; + } + + /** + * Portably retrieve the data of a node; deals with older versions + * of libxml like 2.7.6 + * @param DOMNode $node + */ + protected function getData($node) + { + if (property_exists($node, 'data')) { + return $node->data; + } else if (property_exists($node, 'nodeValue')) { + return $node->nodeValue; + } else if (property_exists($node, 'textContent')) { + return $node->textContent; + } + return null; + } + + + /** * @param DOMNode $node DOMNode to be tokenized. * @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tokens. * @param bool $collect Says whether or start and close are collected, set to @@ -141,7 +176,10 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer // but we're not getting the character reference nodes because // those should have been preprocessed if ($node->nodeType === XML_TEXT_NODE) { - $tokens[] = $this->factory->createText($node->data); + $data = $this->getData($node); // Handle variable data property + if ($data !== null) { + $tokens[] = $this->factory->createText($data); + } return false; } elseif ($node->nodeType === XML_CDATA_SECTION_NODE) { // undo libxml's special treatment of <script> and <style> tags @@ -171,21 +209,20 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer // not-well tested: there may be other nodes we have to grab return false; } - $attr = $node->hasAttributes() ? $this->transformAttrToAssoc($node->attributes) : array(); - + $tag_name = $this->getTagName($node); // Handle variable tagName property + if (empty($tag_name)) { + return (bool) $node->childNodes->length; + } // We still have to make sure that the element actually IS empty if (!$node->childNodes->length) { if ($collect) { - $tokens[] = $this->factory->createEmpty($node->tagName, $attr); + $tokens[] = $this->factory->createEmpty($tag_name, $attr); } return false; } else { if ($collect) { - $tokens[] = $this->factory->createStart( - $tag_name = $node->tagName, // somehow, it get's dropped - $attr - ); + $tokens[] = $this->factory->createStart($tag_name, $attr); } return true; } @@ -197,10 +234,10 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer */ protected function createEndNode($node, &$tokens) { - $tokens[] = $this->factory->createEnd($node->tagName); + $tag_name = $this->getTagName($node); // Handle variable tagName property + $tokens[] = $this->factory->createEnd($tag_name); } - /** * Converts a DOMNamedNodeMap of DOMAttr objects into an assoc array. * diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php index 0b452d17f..72476ddf3 100644 --- a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php @@ -1507,7 +1507,7 @@ class HTML5 $entity = $this->character($start, $this->char); $cond = strlen($e_name) > 0; - // The rest of the parsing happens bellow. + // The rest of the parsing happens below. break; // Anything else @@ -1535,7 +1535,7 @@ class HTML5 } $cond = isset($entity); - // The rest of the parsing happens bellow. + // The rest of the parsing happens below. break; } |