summaryrefslogtreecommitdiff
path: root/uri.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2009-10-02 17:29:48 +0200
committerDaniel Veillard <veillard@redhat.com>2009-10-02 17:29:48 +0200
commit1358fef9aa2c3fea5ed3d6ee50c7eb4d6f92b247 (patch)
tree2a28f537daea7f1b1946b7f773893a2ead81b7db /uri.c
parent243b034d4588ddd45168badcefe3d41e586568f3 (diff)
downloadlibxml2-1358fef9aa2c3fea5ed3d6ee50c7eb4d6f92b247.tar.gz
URI with no path parsing problem
* uri.c: Ralf Junker pointed out that URI with no path like http://www.domain.com when parsed ended up with an empty path value instead of NULL, this fixes the problem
Diffstat (limited to 'uri.c')
-rw-r--r--uri.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/uri.c b/uri.c
index 1e5e03f5..950e177b 100644
--- a/uri.c
+++ b/uri.c
@@ -558,10 +558,14 @@ xmlParse3986PathAbEmpty(xmlURIPtr uri, const char **str)
}
if (uri != NULL) {
if (uri->path != NULL) xmlFree(uri->path);
- if (uri->cleanup & 2)
- uri->path = STRNDUP(*str, cur - *str);
- else
- uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ if (*str != cur) {
+ if (uri->cleanup & 2)
+ uri->path = STRNDUP(*str, cur - *str);
+ else
+ uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ } else {
+ uri->path = NULL;
+ }
}
*str = cur;
return (0);
@@ -600,10 +604,14 @@ xmlParse3986PathAbsolute(xmlURIPtr uri, const char **str)
}
if (uri != NULL) {
if (uri->path != NULL) xmlFree(uri->path);
- if (uri->cleanup & 2)
- uri->path = STRNDUP(*str, cur - *str);
- else
- uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ if (cur != *str) {
+ if (uri->cleanup & 2)
+ uri->path = STRNDUP(*str, cur - *str);
+ else
+ uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ } else {
+ uri->path = NULL;
+ }
}
*str = cur;
return (0);
@@ -638,10 +646,14 @@ xmlParse3986PathRootless(xmlURIPtr uri, const char **str)
}
if (uri != NULL) {
if (uri->path != NULL) xmlFree(uri->path);
- if (uri->cleanup & 2)
- uri->path = STRNDUP(*str, cur - *str);
- else
- uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ if (cur != *str) {
+ if (uri->cleanup & 2)
+ uri->path = STRNDUP(*str, cur - *str);
+ else
+ uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ } else {
+ uri->path = NULL;
+ }
}
*str = cur;
return (0);
@@ -676,10 +688,14 @@ xmlParse3986PathNoScheme(xmlURIPtr uri, const char **str)
}
if (uri != NULL) {
if (uri->path != NULL) xmlFree(uri->path);
- if (uri->cleanup & 2)
- uri->path = STRNDUP(*str, cur - *str);
- else
- uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ if (cur != *str) {
+ if (uri->cleanup & 2)
+ uri->path = STRNDUP(*str, cur - *str);
+ else
+ uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ } else {
+ uri->path = NULL;
+ }
}
*str = cur;
return (0);