mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
trying to fix #114277 about when file remapping and escaping should really
* parser.c xmlIO.c: trying to fix #114277 about when file remapping and escaping should really be attempted. Daniel
This commit is contained in:
@ -1,3 +1,8 @@
|
||||
Mon Jun 9 12:28:58 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* parser.c xmlIO.c: trying to fix #114277 about when file
|
||||
remapping and escaping should really be attempted.
|
||||
|
||||
Mon Jun 9 11:06:09 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* doc/*: applied a patch from Gman for building docs
|
||||
|
11
parser.c
11
parser.c
@ -10558,7 +10558,6 @@ xmlCreateFileParserCtxt(const char *filename)
|
||||
{
|
||||
xmlParserCtxtPtr ctxt;
|
||||
xmlParserInputPtr inputStream;
|
||||
char *canonicFilename;
|
||||
char *directory = NULL;
|
||||
|
||||
ctxt = xmlNewParserCtxt();
|
||||
@ -10569,16 +10568,8 @@ xmlCreateFileParserCtxt(const char *filename)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
canonicFilename = (char *) xmlCanonicPath((const xmlChar *) filename);
|
||||
if (canonicFilename == NULL) {
|
||||
if (xmlDefaultSAXHandler.error != NULL) {
|
||||
xmlDefaultSAXHandler.error(NULL, "out of memory\n");
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
inputStream = xmlLoadExternalEntity(canonicFilename, NULL, ctxt);
|
||||
xmlFree(canonicFilename);
|
||||
inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
|
||||
if (inputStream == NULL) {
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(NULL);
|
||||
|
28
xmlIO.c
28
xmlIO.c
@ -532,20 +532,22 @@ xmlGzfileOpen_real (const char *filename) {
|
||||
* xmlGzfileOpen:
|
||||
* @filename: the URI for matching
|
||||
*
|
||||
* Wrapper around xmlGzfileOpen that try it with an unescaped
|
||||
* version of @filename, if this fails fallback to @filename
|
||||
* Wrapper around xmlGzfileOpen if the open fais, it will
|
||||
* try to unescape @filename
|
||||
*/
|
||||
static void *
|
||||
xmlGzfileOpen (const char *filename) {
|
||||
char *unescaped;
|
||||
void *retval;
|
||||
|
||||
retval = xmlGzfileOpen_real(filename);
|
||||
if (retval == NULL) {
|
||||
unescaped = xmlURIUnescapeString(filename, 0, NULL);
|
||||
if (unescaped != NULL) {
|
||||
retval = xmlGzfileOpen_real(unescaped);
|
||||
} else {
|
||||
retval = xmlGzfileOpen_real(filename);
|
||||
}
|
||||
xmlFree(unescaped);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2487,7 +2489,6 @@ xmlParserGetDirectory(const char *filename) {
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
#ifdef LIBXML_CATALOG_ENABLED
|
||||
static int xmlSysIDExists(const char *URL) {
|
||||
#ifdef HAVE_STAT
|
||||
int ret;
|
||||
@ -2517,7 +2518,6 @@ static int xmlSysIDExists(const char *URL) {
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlDefaultExternalEntityLoader:
|
||||
@ -2669,6 +2669,22 @@ xmlGetExternalEntityLoader(void) {
|
||||
xmlParserInputPtr
|
||||
xmlLoadExternalEntity(const char *URL, const char *ID,
|
||||
xmlParserCtxtPtr ctxt) {
|
||||
if ((URL != NULL) && (xmlSysIDExists(URL) == 0)) {
|
||||
char *canonicFilename;
|
||||
xmlParserInputPtr ret;
|
||||
|
||||
canonicFilename = (char *) xmlCanonicPath((const xmlChar *) URL);
|
||||
if (canonicFilename == NULL) {
|
||||
if (xmlDefaultSAXHandler.error != NULL) {
|
||||
xmlDefaultSAXHandler.error(NULL, "out of memory\n");
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ret = xmlCurrentExternalEntityLoader(canonicFilename, ID, ctxt);
|
||||
xmlFree(canonicFilename);
|
||||
return(ret);
|
||||
}
|
||||
return(xmlCurrentExternalEntityLoader(URL, ID, ctxt));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user