--- embedaddon/libxml2/xinclude.c 2012/02/21 23:37:58 1.1.1.1 +++ embedaddon/libxml2/xinclude.c 2013/07/22 01:22:18 1.1.1.2 @@ -1796,6 +1796,8 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlC 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 xmlC /* * 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 xmlC } xmlBufferShrink(buf->buffer, len); } - xmlFreeParserInputBuffer(buf); + xmlFreeParserCtxt(pctxt); xmlXIncludeAddTxt(ctxt, node, URL); + xmlFreeInputStream(inputStream); loaded: /*