[libxml2] Activate detection of encoding in external subset



commit ab0e35044c0e83936a8042de3dcee328173c273b
Author: Daniel Veillard <veillard redhat com>
Date:   Wed Mar 27 13:21:38 2013 +0800

    Activate detection of encoding in external subset
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694228
    
    the ctxt->encoding was percolated down when parsing the external
    subset leading to failures

 SAX2.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/SAX2.c b/SAX2.c
index c7ecd7f..4adf202 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -411,6 +411,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
        xmlParserInputPtr input = NULL;
        xmlCharEncoding enc;
        int oldcharset;
+       const xmlChar *oldencoding;
 
        /*
         * Ask the Entity resolver to load the damn thing
@@ -432,6 +433,8 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
        oldinputMax = ctxt->inputMax;
        oldinputTab = ctxt->inputTab;
        oldcharset = ctxt->charset;
+       oldencoding = ctxt->encoding;
+       ctxt->encoding = NULL;
 
        ctxt->inputTab = (xmlParserInputPtr *)
                         xmlMalloc(5 * sizeof(xmlParserInputPtr));
@@ -442,6 +445,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
            ctxt->inputMax = oldinputMax;
            ctxt->inputTab = oldinputTab;
            ctxt->charset = oldcharset;
+           ctxt->encoding = oldencoding;
            return;
        }
        ctxt->inputNr = 0;
@@ -487,6 +491,11 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
        ctxt->inputMax = oldinputMax;
        ctxt->inputTab = oldinputTab;
        ctxt->charset = oldcharset;
+       if ((ctxt->encoding != NULL) &&
+           ((ctxt->dict == NULL) ||
+            (!xmlDictOwns(ctxt->dict, ctxt->encoding))))
+           xmlFree((xmlChar *) ctxt->encoding);
+       ctxt->encoding = oldencoding;
        /* ctxt->wellFormed = oldwellFormed; */
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]