diff options
author | Shaun McCance <shaunm@gnome.org> | 2012-05-10 20:59:33 +0800 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2012-05-10 20:59:33 +0800 |
commit | 4cf7325e1f5d6b727bae8f01851c759e49a9d05d (patch) | |
tree | 255cffc11e39e69e0a75e491aa5b8ef5a2c7e325 /xinclude.c | |
parent | fdf990c2ef2ccf1b4fadf24ded562857d187be78 (diff) | |
download | android_external_libxml2-4cf7325e1f5d6b727bae8f01851c759e49a9d05d.tar.gz android_external_libxml2-4cf7325e1f5d6b727bae8f01851c759e49a9d05d.tar.bz2 android_external_libxml2-4cf7325e1f5d6b727bae8f01851c759e49a9d05d.zip |
xinclude with parse="text" does not use the entity loader
For https://bugzilla.gnome.org/show_bug.cgi?id=552479
The code for xinclude parse="text" was not using the registered
entity loader, defeating attempts to control loading of files.
Diffstat (limited to 'xinclude.c')
-rw-r--r-- | xinclude.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -1796,6 +1796,8 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { int i; xmlChar *encoding = NULL; xmlCharEncoding enc = (xmlCharEncoding) 0; + xmlParserCtxtPtr pctxt; + xmlParserInputPtr inputStream; /* * Check the URL and remove any fragment identifier @@ -1870,11 +1872,23 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { /* * Load it. */ - buf = xmlParserInputBufferCreateFilename((const char *)URL, enc); + pctxt = xmlNewParserCtxt(); + inputStream = xmlLoadExternalEntity((const char*)URL, NULL, pctxt); + if(inputStream == NULL) { + xmlFreeParserCtxt(pctxt); + xmlFree(URL); + return(-1); + } + buf = inputStream->buf; if (buf == NULL) { + xmlFreeInputStream (inputStream); + xmlFreeParserCtxt(pctxt); xmlFree(URL); return(-1); } + if (buf->encoder) + xmlCharEncCloseFunc(buf->encoder); + buf->encoder = xmlGetCharEncodingHandler(enc); node = xmlNewText(NULL); /* @@ -1905,8 +1919,9 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { } xmlBufferShrink(buf->buffer, len); } - xmlFreeParserInputBuffer(buf); + xmlFreeParserCtxt(pctxt); xmlXIncludeAddTxt(ctxt, node, URL); + xmlFreeInputStream(inputStream); loaded: /* |