diff options
author | Mike Hommey <glandium@debian.org> | 2008-04-09 10:33:41 +0200 |
---|---|---|
committer | Mike Hommey <glandium@debian.org> | 2008-04-09 10:33:41 +0200 |
commit | 88f9c7ca80bfbc9a5429fc632b90d6c4a2a2787d (patch) | |
tree | e12ef38cd8eb205c495e5718852d758b95e3a3c6 /uri.c | |
parent | fc760252aba4054a612dd20b803d0c7c19713064 (diff) | |
download | libxml2-88f9c7ca80bfbc9a5429fc632b90d6c4a2a2787d.tar.gz |
Load /tmp/libxml2-2.6.32 intoupstream/2.6.32.dfsg
libxml2/branches/upstream/current.
Diffstat (limited to 'uri.c')
-rw-r--r-- | uri.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -421,6 +421,30 @@ xmlSaveUri(xmlURIPtr uri) { } if (uri->path != NULL) { p = uri->path; + /* + * the colon in file:///d: should not be escaped or + * Windows accesses fail later. + */ + if ((uri->scheme != NULL) && + (p[0] == '/') && + (((p[1] >= 'a') && (p[1] <= 'z')) || + ((p[1] >= 'A') && (p[1] <= 'Z'))) && + (p[2] == ':') && + (xmlStrEqual(uri->scheme, BAD_CAST "file"))) { + if (len + 3 >= max) { + max *= 2; + ret = (xmlChar *) xmlRealloc(ret, + (max + 1) * sizeof(xmlChar)); + if (ret == NULL) { + xmlGenericError(xmlGenericErrorContext, + "xmlSaveUri: out of memory\n"); + return(NULL); + } + } + ret[len++] = *p++; + ret[len++] = *p++; + ret[len++] = *p++; + } while (*p != 0) { if (len + 3 >= max) { max *= 2; @@ -2418,6 +2442,11 @@ xmlCanonicPath(const xmlChar *path) if (path == NULL) return(NULL); + + /* sanitize filename starting with // so it can be used as URI */ + if ((path[0] == '/') && (path[1] == '/') && (path[2] != '/')) + path++; + if ((uri = xmlParseURI((const char *) path)) != NULL) { xmlFreeURI(uri); return xmlStrdup(path); |