pattern = $pattern; $this->disableEntityLoaderCheck(); // A fatal error will bypass the destructor, so we register a shutdown here if (!self::$shutdownRegistered) { self::$shutdownRegistered = true; register_shutdown_function([__CLASS__, 'shutdown']); } } public static function getInstance(Reader\IReader $reader): self { $pattern = ($reader instanceof Reader\Html) ? 'callback = $callback; } /** @param mixed $arg */ private static function forceString($arg): string { return is_string($arg) ? $arg : ''; } /** * @param string $xml * * @return string */ private function toUtf8($xml) { $charset = $this->findCharSet($xml); $foundUtf7 = $charset === 'UTF-7'; if ($charset !== 'UTF-8') { $testStart = '/^.{0,4}\s*pattern, 1, 'UTF-8')) . '\0*/'; $xml = "$xml"; if (preg_match($pattern, $xml)) { throw new Reader\Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); } $xml = $this->toUtf8($xml); if (preg_match($pattern, $xml)) { throw new Reader\Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); } if ($this->callback !== null) { $xml = call_user_func($this->callback, $xml); } /** @var string $xml */ return $xml; } /** * Scan the XML for use of scan(file_get_contents($filestream)); } }