Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
anhta opened this issue Mar 8, 2016 · 1 comment

Comments

@anhta
Copy link

anhta commented Mar 8, 2016

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);
      }
@technosophos
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants