[Gd-chatter] r11731 - in trunk/libraries: network/koala/sources/koala uri

turbo24prg at gwydiondylan.org turbo24prg at gwydiondylan.org
Sat Mar 8 18:42:56 CET 2008


Author: turbo24prg
Date: Sat Mar  8 18:42:55 2008
New Revision: 11731

Modified:
   trunk/libraries/network/koala/sources/koala/server.dylan
   trunk/libraries/uri/uri.dylan
Log:
Job: minor
fix percent-encoding/-decoding for uri and koala


Modified: trunk/libraries/network/koala/sources/koala/server.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/server.dylan	(original)
+++ trunk/libraries/network/koala/sources/koala/server.dylan	Sat Mar  8 18:42:55 2008
@@ -903,14 +903,7 @@
   let responders = element(rmap, request.request-method, default: #f);
   if (responders)
     block (return)
-      let tail-path = request.request-tail-url.uri-path;
-      // This isn't using build-path:uri:uri because we don't want it
-      // percent encoded.
-      let url-tail = if (empty?(tail-path))
-                       ""
-                     else
-                       join(tail-path, "/")
-                     end;
+      let url-tail = build-path(request.request-tail-url);
       log-debug("url-tail: %=", url-tail);
       for (actions keyed-by regex in responders)
         log-debug("regex -> actions:  %= -> %=", regex.regex-pattern, actions);

Modified: trunk/libraries/uri/uri.dylan
==============================================================================
--- trunk/libraries/uri/uri.dylan	(original)
+++ trunk/libraries/uri/uri.dylan	Sat Mar  8 18:42:55 2008
@@ -83,10 +83,10 @@
                  port: port & string-to-integer(port),
                  fragment: fragment | "");
   if (~empty?(path))
-    uri.uri-path := split-path(percent-decode(path));
+    uri.uri-path := split-path(path);
   end if;
   if (query)
-    uri.uri-query := split-query(percent-decode(query));
+    uri.uri-query := split-query(query);
   end if;
   if (absolute?(uri))
     uri.uri-path := remove-dot-segments(uri.uri-path);
@@ -109,7 +109,8 @@
 // split parts 
 
 define method split-path (path :: <string>) => (parts :: <sequence>);
-  split(path, "/", remove-if-empty: #f);
+  let parts = split(path, "/", remove-if-empty: #f);
+  map(percent-decode, parts);
 end;
 
 define method split-query
@@ -121,6 +122,7 @@
     let (qname, qvalue) = apply(values, split(part, "=",
                                               remove-if-empty: #f,
                                               count: 2));
+    qname := percent-decode(qname);
     // Right now "&foo=&" is different from &foo&.  The former sets the
     // qvalue to "" and the latter sets it to #t.  Does it matter?  Is
     // &foo& even valid?
@@ -349,6 +351,9 @@
 
 
 begin
+  let foo = parse-url("http://baz.blub/pat%2fh/test?fo%20o=ba%2f%20r");
+  format-out("%s, %=,%s\n", foo.uri-query, foo.uri-path, foo);
+
 /*
   format-out("%s\n", split-query("foo=bar+blub&baz", replacements: list(pair("\\+", " ")))["foo"]);
 



More information about the chatter mailing list