Re: [xml] spaces in uri, again




  yes it should be, %xy with x and y being numbers should not be modified by
any URI escaping routing, that would be another bug.


I also looked at xslt code - in transform.c there's an attempt to build URI
from string and then, when failed, it is repeated with escaped string. Perhaps
the same thing could be done in xmlCanonicPath() ?


  the problem is that the escaping may turn http:// into http%3A// again
that sounds wrong, we should fix that part once and for good, checking all
the different cases.

There's a patch for xmlCanonicPath() that, when xmlParseURI(path) fails, tries
to repeat it with 'path' escaped. I'm  using xmlURIEscapeStr(path,":/?_.#&;=")
so '%' are escaped. I think it is ok, beacuse if user passed already escaped
path, it shouldn't reach that part of code. And if not, we can assume that
string is unescaped, so '%20' means '%2520' and not ' '.
It works for me on http:// paths and on local files with names containing
spaces, '%' and so on.

But there's still another problem I signalled - nanohttp context contains
unescaped strings and HTTP queries are build from unescaped strings. So
'a%20b' becomes 'a b' in HTTP query, which is wrong.

There are two solutions:
- do not unescape strings while building uri (why are they escaped?)
- escape them again when creating HTTP query
Which way?

P.P>
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       4 Aug 2005 13:36:44 -0000
@@ -2231,6 +2231,7 @@
 #endif
     xmlChar *ret;
     xmlURIPtr uri;
+    xmlChar *escURI;
 
     if (path == NULL)
        return(NULL);
@@ -2239,6 +2240,17 @@
        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) {
         return(NULL);


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