Re: [xml] spaces in uri, again




I'm sending another patch:

- for uri.c - some characters added to second argument of xmlURIEscapeStr() to be a little more RFC2396 compatible (so please ignore previous patch) - for nanohttp.c - uri fragments are escaped while creating nanohttp context, so they are properly escaped in HTTP request

I know it isn't the best solution because some strange urls can be messed up with escaping/unescaping. But at least I can get 'http://alpha/~pawel/żółty żółw.xml' from my server, which is not possible with current libxml2 state.

Paweł Pałucha
Index: uri.c
===================================================================
RCS file: /cvs/gnome/libxml2/uri.c,v
retrieving revision 1.73
diff -u -r1.73 uri.c
--- uri.c       25 Jul 2005 18:39:34 -0000      1.73
+++ uri.c       5 Aug 2005 09:41:16 -0000
@@ -2231,13 +2231,24 @@
 #endif
     xmlChar *ret;
     xmlURIPtr uri;
-
+    xmlChar *escURI;
+    
     if (path == NULL)
        return(NULL);
     if ((uri = xmlParseURI((const char *) path)) != NULL) {
        xmlFreeURI(uri);
        return xmlStrdup(path);
     }
+    /* try to build URI from escaped path */
+    escURI = xmlURIEscapeStr(path, ":/?_.#&;=");
+    if (escURI != NULL) {
+           uri = xmlParseURI((const char *) escURI);
+           if (uri != NULL) {
+                   xmlFreeURI(uri);
+                   return escURI;
+           }
+           xmlFree(escURI);
+    }
 
     uri = xmlCreateURI();
     if (uri == NULL) {
Index: nanohttp.c
===================================================================
RCS file: /cvs/gnome/libxml2/nanohttp.c,v
retrieving revision 1.90
diff -u -r1.90 nanohttp.c
--- nanohttp.c  12 Jul 2005 15:09:53 -0000      1.90
+++ nanohttp.c  5 Aug 2005 09:41:17 -0000
@@ -302,14 +302,14 @@
        return;
     }
     
-    ctxt->protocol = xmlMemStrdup(uri->scheme);
-    ctxt->hostname = xmlMemStrdup(uri->server);
+    ctxt->protocol = xmlURIEscapeStr(uri->scheme, BAD_CAST "+-.");
+    ctxt->hostname = xmlURIEscapeStr(uri->server, BAD_CAST "/?;:@");
     if (uri->path != NULL)
-       ctxt->path = xmlMemStrdup(uri->path);
+       ctxt->path = xmlURIEscapeStr(uri->path, BAD_CAST ":@&=+$,/?;");
     else
        ctxt->path = xmlMemStrdup("/");
     if (uri->query != NULL)
-       ctxt->query = xmlMemStrdup(uri->query);
+       ctxt->query = xmlURIEscapeStr(uri->query, BAD_CAST ";/?:@&=+,$");
     if (uri->port != 0)
        ctxt->port = uri->port;
 


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