From fe3969f3759998d3f567a6769535640be69ea1e9 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 27 Jan 2015 09:17:15 +0100 Subject: remove xxe checks for loadHML since it is apparenly no possible to exploit it --- appinfo/autoload.php | 11 - articleenhancer/globalarticleenhancer.php | 11 +- articleenhancer/xpatharticleenhancer.php | 20 +- vendor/ZendXml/.gitignore | 5 - vendor/ZendXml/.travis.yml | 29 -- vendor/ZendXml/README.md | 50 --- vendor/ZendXml/composer.json | 40 --- .../ZendXml/Exception/ExceptionInterface.php | 14 - .../ZendXml/Exception/InvalidArgumentException.php | 17 - .../library/ZendXml/Exception/RuntimeException.php | 17 - vendor/ZendXml/library/ZendXml/Security.php | 168 --------- vendor/ZendXml/tests/Bootstrap.php | 92 ----- vendor/ZendXml/tests/ZendXmlTest/SecurityTest.php | 152 -------- vendor/ZendXml/tests/phpunit.xml.dist | 27 -- vendor/ZendXml/vendor/autoload.php | 7 - vendor/ZendXml/vendor/composer/ClassLoader.php | 383 --------------------- .../ZendXml/vendor/composer/autoload_classmap.php | 9 - .../vendor/composer/autoload_namespaces.php | 10 - vendor/ZendXml/vendor/composer/autoload_psr4.php | 10 - vendor/ZendXml/vendor/composer/autoload_real.php | 50 --- 20 files changed, 14 insertions(+), 1108 deletions(-) delete mode 100644 vendor/ZendXml/.gitignore delete mode 100644 vendor/ZendXml/.travis.yml delete mode 100644 vendor/ZendXml/README.md delete mode 100644 vendor/ZendXml/composer.json delete mode 100644 vendor/ZendXml/library/ZendXml/Exception/ExceptionInterface.php delete mode 100644 vendor/ZendXml/library/ZendXml/Exception/InvalidArgumentException.php delete mode 100644 vendor/ZendXml/library/ZendXml/Exception/RuntimeException.php delete mode 100644 vendor/ZendXml/library/ZendXml/Security.php delete mode 100644 vendor/ZendXml/tests/Bootstrap.php delete mode 100644 vendor/ZendXml/tests/ZendXmlTest/SecurityTest.php delete mode 100755 vendor/ZendXml/tests/phpunit.xml.dist delete mode 100644 vendor/ZendXml/vendor/autoload.php delete mode 100644 vendor/ZendXml/vendor/composer/ClassLoader.php delete mode 100644 vendor/ZendXml/vendor/composer/autoload_classmap.php delete mode 100644 vendor/ZendXml/vendor/composer/autoload_namespaces.php delete mode 100644 vendor/ZendXml/vendor/composer/autoload_psr4.php delete mode 100644 vendor/ZendXml/vendor/composer/autoload_real.php diff --git a/appinfo/autoload.php b/appinfo/autoload.php index 43af4eb33..8b24fea83 100644 --- a/appinfo/autoload.php +++ b/appinfo/autoload.php @@ -17,14 +17,3 @@ // composer libs require_once __DIR__ . '/../vendor/autoload.php'; - -// non composer libs -$thirdPartyLibs = [ - '\ZendXML\Security' => 'ZendXml/vendor/autoload.php', -]; - -foreach ($thirdPartyLibs as $class => $path) { - if (!class_exists($class)) { - require_once __DIR__ . '/../vendor/' . $path; - } -} diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php index 1939ca41c..004d92a9f 100644 --- a/articleenhancer/globalarticleenhancer.php +++ b/articleenhancer/globalarticleenhancer.php @@ -13,7 +13,8 @@ namespace OCA\News\ArticleEnhancer; -use \ZendXml\Security; +use DomDocument; +use DOMXpath; use \OCA\News\Db\Item; @@ -26,17 +27,15 @@ class GlobalArticleEnhancer implements ArticleEnhancer { */ public function enhance(Item $item) { - $dom = new \DOMDocument(); + $dom = new DOMDocument(); // wrap it inside a div if there is none to prevent invalid wrapping // inside

tags $body = '

' . $item->getBody() . '
'; - $isOk = Security::scanHtml( - $body, $dom, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD - ); + @$dom->loadHTML($body, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); - $xpath = new \DOMXpath($dom); + $xpath = new DOMXpath($dom); // remove youtube autoplay // NOTE: PHP supports only XPath 1.0 so no matches() function :( diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index 42b2edf0c..67fbf78d2 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -13,15 +13,15 @@ namespace OCA\News\ArticleEnhancer; -use \DOMDocument; -use \DOMXpath; +use DOMDocument; +use DOMXpath; -use \ZendXml\Security; -use \PicoFeed\Encoding\Encoding; +use PicoFeed\Encoding\Encoding; -use \OCA\News\Utility\PicoFeedClientFactory; +use OCA\News\Utility\PicoFeedClientFactory; + +use OCA\News\Db\Item; -use \OCA\News\Db\Item; class XPathArticleEnhancer implements ArticleEnhancer { @@ -72,8 +72,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { } $dom = new DOMDocument(); - - $isOk = Security::scanHtml($body, $dom); + @$dom->loadHTML($body); $xpath = new DOMXpath($dom); $xpathResult = $xpath->evaluate($search); @@ -127,9 +126,8 @@ class XPathArticleEnhancer implements ArticleEnhancer { } $xmlString = '
' . $xmlString . '
'; - $isOk = Security::scanHtml( - $xmlString, $dom, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD - ); + $isOk = @$dom->loadHTML($xmlString, LIBXML_HTML_NOIMPLIED | + LIBXML_HTML_NODEFDTD); if(!$isOk) { return false; diff --git a/vendor/ZendXml/.gitignore b/vendor/ZendXml/.gitignore deleted file mode 100644 index 0a4f6e27f..000000000 --- a/vendor/ZendXml/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -composer.lock -vendor -.buildpath -.project -.settings diff --git a/vendor/ZendXml/.travis.yml b/vendor/ZendXml/.travis.yml deleted file mode 100644 index ad8db966f..000000000 --- a/vendor/ZendXml/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: php -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm - -matrix: - allow_failures: - - php: hhvm - -before_install: - # need to update libxml to 2.7.8 to be able to run tests using the - # LIBXML_HTML_NODEFDTD and LIBXML_HTML_NOIMPLIED libxml constant - - sudo apt-get update - - sudo apt-get -o DPkg::Options::="--force-confold" -y upgrade - -before_script: - - composer self-update - - composer install --dev - -script: - - ./vendor/bin/phpunit -c ./tests - - ./vendor/bin/phpcs --standard=PSR2 --ignore=tests/Bootstrap.php library tests - -notifications: - irc: "irc.freenode.org#zftalk.dev" - email: false diff --git a/vendor/ZendXml/README.md b/vendor/ZendXml/README.md deleted file mode 100644 index 2c67008da..000000000 --- a/vendor/ZendXml/README.md +++ /dev/null @@ -1,50 +0,0 @@ -ZendXml -======= - -An utility component for XML usage and best practices in PHP - -Installation ------------- - -You can install using: - -``` -curl -s https://getcomposer.org/installer | php -php composer.phar install -``` - -Notice that this library doesn't have any external dependencies, the usage of composer is for autoloading and standard purpose. - - -ZendXml\Security ----------------- - -This is a security component to prevent [XML eXternal Entity](https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing) (XXE) and [XML Entity Expansion](http://projects.webappsec.org/w/page/13247002/XML%20Entity%20Expansion) (XEE) attacks on XML documents. - -The XXE attack is prevented disabling the load of external entities in the libxml library used by PHP, using the function [libxml_disable_entity_loader](http://www.php.net/manual/en/function.libxml-disable-entity-loader.php). - -The XEE attack is prevented looking inside the XML document for ENTITY usage. If the XML document uses ENTITY the library throw an Exception. - -We have two static methods to scan and load XML document from a string (scan) and from a file (scanFile). You can decide to get a SimpleXMLElement or DOMDocument as result, using the following use cases: - -```php -use ZendXml\Security as XmlSecurity; - -$xml = << - - test - -XML; - -// SimpleXML use case -$simplexml = XmlSecurity::scan($xml); -printf ("SimpleXMLElement: %s\n", ($simplexml instanceof \SimpleXMLElement) ? 'yes' : 'no'); - -// DOMDocument use case -$dom = new \DOMDocument('1.0'); -$dom = XmlSecurity::scan($xml, $dom); -printf ("DOMDocument: %s\n", ($dom instanceof \DOMDocument) ? 'yes' : 'no'); -``` - - diff --git a/vendor/ZendXml/composer.json b/vendor/ZendXml/composer.json deleted file mode 100644 index 139f1e23b..000000000 --- a/vendor/ZendXml/composer.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "zendframework/zendxml", - "description": "Utility library for XML usage, best practices, and security in PHP", - "type": "library", - "license": "BSD-3-Clause", - "keywords": [ - "zf2", - "xml", - "security" - ], - "homepage": "http://packages.zendframework.com/", - "autoload": { - "psr-0": { - "ZendXml\\": "library/" - } - }, - "autoload-dev": { - "psr-4": { - "ZendTest\\Xml\\": "tests/ZendXmlTest/" - } - }, - "repositories": [ - { - "type": "composer", - "url": "http://packages.zendframework.com/" - } - ], - "require": { - "php": ">=5.3.3" - }, - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "require-dev": { - "phpunit/phpunit": "~3.7", - "squizlabs/php_codesniffer": "~1.5" - } -} diff --git a/vendor/ZendXml/library/ZendXml/Exception/ExceptionInterface.php b/vendor/ZendXml/library/ZendXml/Exception/ExceptionInterface.php deleted file mode 100644 index c55eb9034..000000000 --- a/vendor/ZendXml/library/ZendXml/Exception/ExceptionInterface.php +++ /dev/null @@ -1,14 +0,0 @@ - 0) { - return true; - } - return false; - }, E_WARNING); - - $result = $callback($xml, $dom, LIBXML_NONET | $libXmlConstants); - - restore_error_handler(); - - // Entity load to previous setting - if (!self::isPhpFpm()) { - libxml_disable_entity_loader($loadEntities); - libxml_use_internal_errors($useInternalXmlErrors); - } - - if (!$result) { - return false; - } - - // Scan for potential XEE attacks using ENTITY, if not PHP-FPM - if (!self::isPhpFpm()) { - foreach ($dom->childNodes as $child) { - if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { - if ($child->entities->length > 0) { - throw new Exception\RuntimeException(self::ENTITY_DETECT); - } - } - } - } - - if (isset($simpleXml)) { - $result = simplexml_import_dom($dom); - if (!$result instanceof SimpleXMLElement) { - return false; - } - return $result; - } - return $dom; - } - - /** - * Scan HTML string for potential XXE and XEE attacks - * - * @param string $xml - * @param DomDocument $dom - * @param int $libXmlConstants additional libxml constants to pass in - * @throws Exception\RuntimeException - * @return SimpleXMLElement|DomDocument|boolean - */ - public static function scanHtml($html, DOMDocument $dom = null, $libXmlConstants = 0) - { - $callback = function ($html, $dom, $constants) { - return $dom->loadHtml($html, $constants); - }; - return self::scanString($html, $dom, $libXmlConstants, $callback); - } - - /** - * Scan XML string for potential XXE and XEE attacks - * - * @param string $xml - * @param DomDocument $dom - * @param int $libXmlConstants additional libxml constants to pass in - * @throws Exception\RuntimeException - * @return SimpleXMLElement|DomDocument|boolean - */ - public static function scan($xml, DOMDocument $dom = null, $libXmlConstants = 0) - { - $callback = function ($xml, $dom, $constants) { - return $dom->loadXml($xml, $constants); - }; - return self::scanString($xml, $dom, $libXmlConstants, $callback); - } - - /** - * Scan XML file for potential XXE/XEE attacks - * - * @param string $file - * @param DOMDocument $dom - * @throws Exception\InvalidArgumentException - * @return SimpleXMLElement|DomDocument - */ - public static function scanFile($file, DOMDocument $dom = null) - { - if (!file_exists($file)) { - throw new Exception\InvalidArgumentException( - "The file $file specified doesn't exist" - ); - } - return self::scan(file_get_contents($file), $dom); - } - - /** - * Return true if PHP is running with PHP-FPM - * - * @return boolean - */ - public static function isPhpFpm() - { - if (substr(php_sapi_name(), 0, 3) === 'fpm') { - return true; - } - return false; - } -} diff --git a/vendor/ZendXml/tests/Bootstrap.php b/vendor/ZendXml/tests/Bootstrap.php deleted file mode 100644 index a9d0e6a55..000000000 --- a/vendor/ZendXml/tests/Bootstrap.php +++ /dev/null @@ -1,92 +0,0 @@ -addDirectoryToWhitelist($zfCoreLibrary . '/' . $lastArg); - } elseif (is_file($zfCoreTests . '/' . $lastArg)) { - $codeCoverageFilter->addDirectoryToWhitelist(dirname($zfCoreLibrary . '/' . $lastArg)); - } else { - $codeCoverageFilter->addDirectoryToWhitelist($zfCoreLibrary); - } - - /* - * Omit from code coverage reports the contents of the tests directory - */ - $codeCoverageFilter->addDirectoryToBlacklist($zfCoreTests, ''); - $codeCoverageFilter->addDirectoryToBlacklist(PEAR_INSTALL_DIR, ''); - $codeCoverageFilter->addDirectoryToBlacklist(PHP_LIBDIR, ''); - - unset($codeCoverageFilter); -} - -/* - * Unset global variables that are no longer needed. - */ -unset($phpUnitVersion); diff --git a/vendor/ZendXml/tests/ZendXmlTest/SecurityTest.php b/vendor/ZendXml/tests/ZendXmlTest/SecurityTest.php deleted file mode 100644 index 0f0fbffba..000000000 --- a/vendor/ZendXml/tests/ZendXmlTest/SecurityTest.php +++ /dev/null @@ -1,152 +0,0 @@ - -]> - - This result is &harmless; - -XML; - - $this->setExpectedException('ZendXml\Exception\RuntimeException'); - $result = XmlSecurity::scan($xml); - } - - public function testScanForXXE() - { - $file = tempnam(sys_get_temp_dir(), 'ZendXml_Security'); - file_put_contents($file, 'This is a remote content!'); - $xml = << - -]> - - &foo; - -XML; - - try { - $result = XmlSecurity::scan($xml); - } catch (Exception\RuntimeException $e) { - unlink($file); - return; - } - $this->fail('An expected exception has not been raised.'); - } - - public function testScanSimpleXmlResult() - { - $result = XmlSecurity::scan($this->getXml()); - $this->assertTrue($result instanceof SimpleXMLElement); - $this->assertEquals($result->result, 'test'); - } - - public function testScanDom() - { - $dom = new DOMDocument('1.0'); - $result = XmlSecurity::scan($this->getXml(), $dom); - $this->assertTrue($result instanceof DOMDocument); - $node = $result->getElementsByTagName('result')->item(0); - $this->assertEquals($node->nodeValue, 'test'); - } - - /** - * @requires PHP 5.4 - */ - public function testScanDomHTML() - { - // loadHtml accepts constants in php >= 5.4 - // http://php.net/manual/de/domdocument.loadhtml.php - $dom = new DOMDocument('1.0'); - $html = <<a simple test

-HTML; - $constants = LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED; - $result = XmlSecurity::scanHtml($html, $dom, $constants); - $this->assertTrue($result instanceof DOMDocument); - $this->assertEquals($html, trim($result->saveHtml())); - } - - public function testScanInvalidXml() - { - $xml = <<test -XML; - - $result = XmlSecurity::scan($xml); - $this->assertFalse($result); - } - - public function testScanInvalidXmlDom() - { - $xml = <<test -XML; - - $dom = new DOMDocument('1.0'); - $result = XmlSecurity::scan($xml, $dom); - $this->assertFalse($result); - } - - public function testScanFile() - { - $file = tempnam(sys_get_temp_dir(), 'ZendXml_Security'); - file_put_contents($file, $this->getXml()); - - $result = XmlSecurity::scanFile($file); - $this->assertTrue($result instanceof SimpleXMLElement); - $this->assertEquals($result->result, 'test'); - unlink($file); - } - - public function testScanXmlWithDTD() - { - $xml = << - - -]> - - test - -XML; - - $dom = new DOMDocument('1.0'); - $result = XmlSecurity::scan($xml, $dom); - $this->assertTrue($result instanceof DOMDocument); - $this->assertTrue($result->validate()); - } - - protected function getXml() - { - return << - - test - -XML; - } -} diff --git a/vendor/ZendXml/tests/phpunit.xml.dist b/vendor/ZendXml/tests/phpunit.xml.dist deleted file mode 100755 index 069784bd7..000000000 --- a/vendor/ZendXml/tests/phpunit.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - ./ZendXmlTest - ./ZendXmlTest/TestAsset - - - - - - - - - - - - - - ./ZendXmlTest - ../vendor - - - - - - - diff --git a/vendor/ZendXml/vendor/autoload.php b/vendor/ZendXml/vendor/autoload.php deleted file mode 100644 index ec43ad18d..000000000 --- a/vendor/ZendXml/vendor/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0 class loader - * - * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - - public function getPrefixes() - { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-0 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if ($file === null && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if ($file === null) { - // Remember that this class does not exist. - return $this->classMap[$class] = false; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/vendor/ZendXml/vendor/composer/autoload_classmap.php b/vendor/ZendXml/vendor/composer/autoload_classmap.php deleted file mode 100644 index 7a91153b0..000000000 --- a/vendor/ZendXml/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,9 +0,0 @@ - array($baseDir . '/library'), -); diff --git a/vendor/ZendXml/vendor/composer/autoload_psr4.php b/vendor/ZendXml/vendor/composer/autoload_psr4.php deleted file mode 100644 index 9c321972e..000000000 --- a/vendor/ZendXml/vendor/composer/autoload_psr4.php +++ /dev/null @@ -1,10 +0,0 @@ - array($baseDir . '/tests/ZendXmlTest'), -); diff --git a/vendor/ZendXml/vendor/composer/autoload_real.php b/vendor/ZendXml/vendor/composer/autoload_real.php deleted file mode 100644 index b881772be..000000000 --- a/vendor/ZendXml/vendor/composer/autoload_real.php +++ /dev/null @@ -1,50 +0,0 @@ - $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - - $loader->register(true); - - return $loader; - } -} - -function composerRequireea88c51e6ab35b96029638db6e4797bb($file) -{ - require $file; -} -- cgit v1.2.3