This patch allows xmlParseURI() to remember whether double slashes were used and make xmlSaveUri() use that information. Below is the difference when $uri is processed with xmlSaveUri(xmlParseURI($uri)):
Before: "scheme:noserver" -> scheme://noserver" "scheme:/noserver" -> scheme:///noserver" After: "scheme:noserver" -> scheme:noserver" "scheme:/noserver" -> scheme:/noserver" Signed-off-by: Martin Kletzander <mklet...@redhat.com> --- include/libxml/uri.h | 1 + uri.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/libxml/uri.h b/include/libxml/uri.h index db48262..f985c22 100644 --- a/include/libxml/uri.h +++ b/include/libxml/uri.h @@ -42,6 +42,7 @@ struct _xmlURI { char *fragment; /* the fragment identifier */ int cleanup; /* parsing potentially unclean URI */ char *query_raw; /* the query string (as it appears in the URI) */ + int slashes_used; /* uri was specified with "//" */ }; /* diff --git a/uri.c b/uri.c index 4ab0ce2..15e7076 100644 --- a/uri.c +++ b/uri.c @@ -756,6 +756,7 @@ xmlParse3986HierPart(xmlURIPtr uri, const char **str) cur = *str; if ((*cur == '/') && (*(cur + 1) == '/')) { + uri->slashes_used = 1; cur += 2; ret = xmlParse3986Authority(uri, &cur); if (ret != 0) return(ret); @@ -1188,7 +1189,8 @@ xmlSaveUri(xmlURIPtr uri) { ret[len++] = lo + (lo > 9? 'A'-10 : '0'); } } - } else if (uri->scheme != NULL) { + } else if (uri->scheme != NULL && + uri->slashes_used == 1) { if (len + 3 >= max) { temp = xmlSaveUriRealloc(ret, &max); if (temp == NULL) goto mem_error; -- 2.1.1 _______________________________________________ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org https://mail.gnome.org/mailman/listinfo/xml