libxml2 does not ignore the HTML_PARSE_NOWARNING flag. Calling htmlCtxtUseOptions with HTML_PARSE_NOWARNING causes alert handlers to be unregistered (set to NULL). But the PHP code then proceeds to install its own handlers unconditionally, making the flag useless. The PHP code must either add validation in order to install handlers:
htmlCtxtUseOptions(ctxt, (int)options); if (!(options & HTML_PARSE_NOERROR)) { ctxt->vctxt.error = php_libxml_ctx_error; if (ctxt->sax != NULL) ctxt->sax->error = php_libxml_ctx_error; } if (!(options & HTML_PARSE_NOWARNING)) { ctxt->vctxt.warning = php_libxml_ctx_warning; if (ctxt->sax != NULL) ctxt->sax->warning = php_libxml_ctx_warning; } htmlParseDocument(ctxt);
Or call htmlCtxtUseOptions after setting the handlers:
ctxt->vctxt.error = php_libxml_ctx_error; ctxt->vctxt.warning = php_libxml_ctx_warning; if (ctxt->sax != NULL) { ctxt->sax->error = php_libxml_ctx_error; ctxt->sax->warning = php_libxml_ctx_warning; } htmlCtxtUseOptions(ctxt, (int)options); htmlParseDocument(ctxt);
nwellnhof Jan 26 '17 at 14:37 2017-01-26 14:37
source share