[xml] [PATCH 2/2] uri: don't force double slashes with rootless paths



This changes xmlSaveUri()'s behaviour for two particular URI types,
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 <mkletzan redhat com>
---
 uri.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/uri.c b/uri.c
index 4ab0ce2..4263765 100644
--- a/uri.c
+++ b/uri.c
@@ -1188,7 +1188,8 @@ xmlSaveUri(xmlURIPtr uri) {
                    ret[len++] = lo + (lo > 9? 'A'-10 : '0');
                }
            }
-       } else if (uri->scheme != NULL) {
+       } else if (uri->scheme != NULL &&
+                   uri->path && uri->path[0] == '/') {
            if (len + 3 >= max) {
                 temp = xmlSaveUriRealloc(ret, &max);
                 if (temp == NULL) goto mem_error;
-- 
2.1.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]