--- a/web/lib/Zend/Dom/Query.php Sun Apr 21 10:07:03 2013 +0200
+++ b/web/lib/Zend/Dom/Query.php Sun Apr 21 21:54:24 2013 +0200
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Dom
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Query.php 23062 2010-10-08 14:05:45Z matthew $
+ * @version $Id: Query.php 25033 2012-08-17 19:50:08Z matthew $
*/
/**
@@ -34,7 +34,7 @@
*
* @package Zend_Dom
* @subpackage Query
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dom_Query
@@ -90,8 +90,8 @@
/**
* Set document encoding
- *
- * @param string $encoding
+ *
+ * @param string $encoding
* @return Zend_Dom_Query
*/
public function setEncoding($encoding)
@@ -102,7 +102,7 @@
/**
* Get document encoding
- *
+ *
* @return null|string
*/
public function getEncoding()
@@ -124,6 +124,10 @@
}
// breaking XML declaration to make syntax highlighting work
if ('<' . '?xml' == substr(trim($document), 0, 5)) {
+ if (preg_match('/<html[^>]*xmlns="([^"]+)"[^>]*>/i', $document, $matches)) {
+ $this->_xpathNamespaces[] = $matches[1];
+ return $this->setDocumentXhtml($document, $encoding);
+ }
return $this->setDocumentXml($document, $encoding);
}
if (strstr($document, 'DTD XHTML')) {
@@ -205,7 +209,7 @@
/**
* Get any DOMDocument errors found
- *
+ *
* @return false|array
*/
public function getDocumentErrors()
@@ -241,6 +245,7 @@
$encoding = $this->getEncoding();
libxml_use_internal_errors(true);
+ libxml_disable_entity_loader(true);
if (null === $encoding) {
$domDoc = new DOMDocument('1.0');
} else {
@@ -250,6 +255,14 @@
switch ($type) {
case self::DOC_XML:
$success = $domDoc->loadXML($document);
+ foreach ($domDoc->childNodes as $child) {
+ if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
+ require_once 'Zend/Dom/Exception.php';
+ throw new Zend_Dom_Exception(
+ 'Invalid XML: Detected use of illegal DOCTYPE'
+ );
+ }
+ }
break;
case self::DOC_HTML:
case self::DOC_XHTML:
@@ -262,6 +275,7 @@
$this->_documentErrors = $errors;
libxml_clear_errors();
}
+ libxml_disable_entity_loader(false);
libxml_use_internal_errors(false);
if (!$success) {