GravityPDF / querypath

A fork of QueryPath: a PHP library for HTML(5)/XML querying (CSS 4 or XPath) and processing (like jQuery) with PHP8.3 support
Other
23 stars 3 forks source link

DOMQuery::parseXMLFile() should throw exception when DOMDocument fails to load #12

Closed jakejackson1 closed 1 year ago

jakejackson1 commented 1 year ago

From querypath created by anhta: technosophos/querypath#177

You should check for $r === FALSE and throw exception after this piece of codes in DOMQuery::parseXMLFile() as load() and loadHTMLFile() methods of DOMDocument can return FALSE on failure:

      if ($useParser == 'xml') {
        $r = $document->load($filename, $flags);
      }
      // Otherwise, see if it looks like HTML.
      elseif (isset($htmlExtensions[$ext]) || $useParser == 'html') {
        // Try parsing it as HTML.
        $r = $document->loadHTMLFile($filename);
      }
      // Default to XML.
      else {
        $r = $document->load($filename, $flags);
      }
jakejackson1 commented 1 year ago

Feel free to open a PR, and I'l take a look. That'd be a fairly big change, and would likely break many applications, so it'd probably require a major version number increment.