facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.21k stars 3k forks source link

Cannot catch querypath parser errors #6982

Open ldct opened 8 years ago

ldct commented 8 years ago

HHVM Version

3.14.0-dev

Standalone code, or other way to reproduce the problem

<?php

include('/path/to/autoload.php');

$qp = htmlqp(QueryPath::XHTML_STUB, 'body', []);

$h = <<<HTML
<div>This is invalid HTML < </div>
HTML;

function errorHandler($errno, $errstr) {
  var_dump('handling error', $errno, $errstr);
}

set_error_handler('errorHandler', E_ERROR | E_WARNING | E_USER_ERROR | E_USER_WARNING);

$qp->html($h);

Expected result

In Zend, the error handler gets called 4 times:

string(14) "handling error"
int(2)
string(95) "DOMDocumentFragment::appendXML(): Entity: line 1: parser error : StartTag: invalid element name"
string(14) "handling error"
int(2)
string(68) "DOMDocumentFragment::appendXML(): <div>This is invalid HTML < </div>"
string(14) "handling error"
int(2)
string(62) "DOMDocumentFragment::appendXML():                            ^"
string(14) "handling error"
int(2)
string(91) "DOMDocumentFragment::appendXML(): Entity: line 1: parser error : chunk is not well balanced"

Actual result

In HHVM, it gets called 0 times:

Entity: line 1: parser error : StartTag: invalid element name
<div>This is invalid HTML < </div>
                           ^
Entity: line 1: parser error : chunk is not well balanced
jesseschalken commented 7 years ago

htmlqp() is part of this library: https://github.com/technosophos/querypath

How are the errors being generated? With trigger_error()? Searching for invalid element name or chunk is not well balanced in the Github code produces no results.