]> granicus.if.org Git - php/commitdiff
if $doc->recover = true; set error_reporting to (old | E_WARNING)
authorChristian Stocker <chregu@php.net>
Wed, 25 Aug 2004 08:27:07 +0000 (08:27 +0000)
committerChristian Stocker <chregu@php.net>
Wed, 25 Aug 2004 08:27:07 +0000 (08:27 +0000)
This way, you can't silence XML parse errors with the @ character

ext/dom/document.c

index 3fcad5cf878ffb41675196238caff3c89eebe0da..90b23f9f43d80e4634c73ce0a451047dad5c7cc8 100644 (file)
@@ -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);