Browse Source

if $doc->recover = true; set error_reporting to (old | E_WARNING)

This way, you can't silence XML parse errors with the @ character
PHP-5.1
Christian Stocker 22 years ago
parent
commit
b96ebb376f
  1. 9
      ext/dom/document.c

9
ext/dom/document.c

@ -1436,6 +1436,7 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source TSRMLS_DC)
php_libxml_ref_obj *document = NULL;
int validate, recover, resolve_externals, keep_blanks, substitute_ent;
int resolved_path_len;
int old_error_reporting;
char *directory=NULL, resolved_path[MAXPATHLEN];
if (id != NULL) {
@ -1510,11 +1511,17 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source TSRMLS_DC)
ctxt->sax->error = php_libxml_ctx_error;
ctxt->sax->warning = php_libxml_ctx_warning;
}
if (recover) {
old_error_reporting = EG(error_reporting);
EG(error_reporting) = old_error_reporting | E_WARNING;
}
xmlParseDocument(ctxt);
if (ctxt->wellFormed || recover) {
ret = ctxt->myDoc;
if (recover) {
EG(error_reporting) = old_error_reporting;
}
/* If loading from memory, set the base reference uri for the document */
if (ret->URL == NULL && ctxt->directory != NULL) {
ret->URL = xmlStrdup(ctxt->directory);

Loading…
Cancel
Save