From ad78dea87abef5ed59e703baa89af52c9ca6de06 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Wed, 23 Nov 2011 11:13:20 -0700 Subject: [PATCH] Revert "This fixes 10497 and potentially breaks programs that assume the query of a URL is always a list. I have fixed uses in the Web Server, which I expect is the major thing affected, but much more could be. Therefore I am skeptical this is a good idea just for the representation of ?. So, I'd like other people to review the change and let me know if they think I should revert it." This reverts commit 7f9818bb3ef2a1818a916a0346d26d5cb4ae5f61. original commit: 41e04b33daf244cf072e5ab0afe32f7ab0cf4eb3 --- collects/tests/net/url.rkt | 81 ++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/collects/tests/net/url.rkt b/collects/tests/net/url.rkt index cca25f8d85..1817082d4b 100644 --- a/collects/tests/net/url.rkt +++ b/collects/tests/net/url.rkt @@ -1,6 +1,6 @@ #lang scheme (require net/url tests/eli-tester - (only-in net/uri-codec current-alist-separator-mode uri-encode)) + (only-in net/uri-codec current-alist-separator-mode)) (define (url->vec url) (vector @@ -50,29 +50,29 @@ (current-proxy-servers)) => '(("http" "proxy.com" 3128))) - (test-s->u #(#f #f #f #f #t (#("")) #f #f) + (test-s->u #(#f #f #f #f #t (#("")) () #f) "/") - (test-s->u #(#f #f #f #f #f () #f #f) + (test-s->u #(#f #f #f #f #f () () #f) "") - (test-s->u #("http" #f #f #f #t (#("")) #f #f) + (test-s->u #("http" #f #f #f #t (#("")) () #f) "http:/") - (test-s->u #("http" #f "" #f #t (#("")) #f #f) + (test-s->u #("http" #f "" #f #t (#("")) () #f) "http:///") - (test-s->u #("http" #f "www.drscheme.org" #f #f () #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #f () () #f) "http://www.drscheme.org") - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("")) () #f) "http://www.drscheme.org/") - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c")) () #f) "http://www.drscheme.org/a/b/c") - (test-s->u #("http" "robby" "www.drscheme.org" #f #t (#("a") #("b") #("c")) #f #f) + (test-s->u #("http" "robby" "www.drscheme.org" #f #t (#("a") #("b") #("c")) () #f) "http://robby@www.drscheme.org/a/b/c") - (test-s->u #("http" #f "www.drscheme.org" 8080 #t (#("a") #("b") #("c")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" 8080 #t (#("a") #("b") #("c")) () #f) "http://www.drscheme.org:8080/a/b/c") - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c")) #f "joe") + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c")) () "joe") "http://www.drscheme.org/a/b/c#joe") (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c")) ((tim . "")) #f) "http://www.drscheme.org/a/b/c?tim=") @@ -90,53 +90,53 @@ (parameterize ([current-alist-separator-mode 'amp]) (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c")) ((tam . "tom") (pam . "pom")) "joe") "http://www.drscheme.org/a/b/c?tam=tom&pam=pom#joe")) - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c" "b")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c" "b")) () #f) "http://www.drscheme.org/a/b/c;b") - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a" "x") #("b") #("c" "b")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a" "x") #("b") #("c" "b")) () #f) "http://www.drscheme.org/a;x/b/c;b") ;; test unquoting for % (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a") #("b") #("c")) ((ti#m . "")) "jo e") "http://www.drscheme.org/a/b/c?ti%23m=#jo%20e") - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a " " a") #(" b ") #(" c ")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a " " a") #(" b ") #(" c ")) () #f) "http://www.drscheme.org/a%20;%20a/%20b%20/%20c%20") - (test-s->u #("http" "robb y" "www.drscheme.org" #f #t (#("")) #f #f) + (test-s->u #("http" "robb y" "www.drscheme.org" #f #t (#("")) () #f) "http://robb%20y@www.drscheme.org/") - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("%a") #("b/") #("c")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("%a") #("b/") #("c")) () #f) "http://www.drscheme.org/%25a/b%2F/c") - (test-s->u #("http" "robby:password" "www.drscheme.org" #f #t (#("")) #f #f) + (test-s->u #("http" "robby:password" "www.drscheme.org" #f #t (#("")) () #f) "http://robby:password@www.drscheme.org/") (test "robby:password" (lambda (x) (url-user (string->url x))) "http://robby%3apassword@www.drscheme.org/") ;; test the characters that need to be encoded in paths vs those that do not need to ;; be encoded in paths - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a:@!$&'()*+,=z") #("/?#[];") #("")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("a:@!$&'()*+,=z") #("/?#[];") #("")) () #f) "http://www.drscheme.org/a:@!$&'()*+,=z/%2F%3F%23%5B%5D%3B/") - (test-s->u #("http" #f "www.drscheme.org" #f #t (#(".") #("..") #(same) #(up) #("...") #("abc.def")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#(".") #("..") #(same) #(up) #("...") #("abc.def")) () #f) "http://www.drscheme.org/%2e/%2e%2e/./../.../abc.def") - (test-s->u #("http" #f "www.drscheme.org" #f #t (#("." "") #(".." "") #(same "") #(up "") #("..." "") #("abc.def" "")) #f #f) + (test-s->u #("http" #f "www.drscheme.org" #f #t (#("." "") #(".." "") #(same "") #(up "") #("..." "") #("abc.def" "")) () #f) "http://www.drscheme.org/%2e;/%2e%2e;/.;/..;/...;/abc.def;") ;; test other scheme identifiers - (test-s->u #("blah" #f "www.foo.com" #f #t (#("")) #f #f) + (test-s->u #("blah" #f "www.foo.com" #f #t (#("")) () #f) "blah://www.foo.com/") - (test-s->u #("blah99" #f "www.foo.com" #f #t (#("")) #f #f) + (test-s->u #("blah99" #f "www.foo.com" #f #t (#("")) () #f) "blah99://www.foo.com/") - (test-s->u #("blah+" #f "www.foo.com" #f #t (#("")) #f #f) + (test-s->u #("blah+" #f "www.foo.com" #f #t (#("")) () #f) "blah+://www.foo.com/") - (test-s->u #("a+b-c456.d" #f "www.foo.com" #f #t (#("")) #f #f) + (test-s->u #("a+b-c456.d" #f "www.foo.com" #f #t (#("")) () #f) "a+b-c456.d://www.foo.com/") ;; a colon and other junk (`sub-delims') can appear in usernames - (test #("http" "x:!$&'()*+,;=y" "www.drscheme.org" #f #t (#("a")) #f #f) + (test #("http" "x:!$&'()*+,;=y" "www.drscheme.org" #f #t (#("a")) () #f) string->url/vec "http://x:!$&'()*+,;=y@www.drscheme.org/a") ;; a colon and atsign can appear in absolute paths - (test-s->u #(#f #f #f #f #t (#("x:@y") #("z")) #f #f) + (test-s->u #(#f #f #f #f #t (#("x:@y") #("z")) () #f) "/x:@y/z") ;; and in relative paths as long as it's not in the first element - (test-s->u #(#f #f #f #f #f (#("x") #("y:@z")) #f #f) + (test-s->u #(#f #f #f #f #f (#("x") #("y:@z")) () #f) "x/y:@z") ;; test bad schemes @@ -148,38 +148,38 @@ (string->url "a b://www.foo.com/") =error> url-exception?) ;; test file: urls - (test-s->u #("file" #f "" #f #t (#("abc") #("def.html")) #f #f) + (test-s->u #("file" #f "" #f #t (#("abc") #("def.html")) () #f) "file:///abc/def.html") (test (url->string (string->url "file:///abc/def.html")) => "file:///abc/def.html") (parameterize ([file-url-path-convention-type 'unix]) (test (url->string (string->url "file://a/b")) => "file://a/b") - (test-s->u #("file" #f "localhost" #f #t (#("abc") #("def.html")) #f #f) + (test-s->u #("file" #f "localhost" #f #t (#("abc") #("def.html")) () #f) "file://localhost/abc/def.html")) ;; test files: urls with colons, and the different parsing on Windows - (test-s->u #("file" #f "localhost" 123 #t (#("abc") #("def.html")) #f #f) + (test-s->u #("file" #f "localhost" 123 #t (#("abc") #("def.html")) () #f) "file://localhost:123/abc/def.html") (parameterize ([file-url-path-convention-type 'unix]) ;; different parse for file://foo:/... (test (string->url/vec "file://foo:/abc/def.html") - => #("file" #f "foo" #f #t (#("abc") #("def.html")) #f #f))) + => #("file" #f "foo" #f #t (#("abc") #("def.html")) () #f))) (parameterize ([file-url-path-convention-type 'windows]) (test (string->url/vec "file://foo:/abc/def.html") - => #("file" #f "" #f #t (#("foo:") #("abc") #("def.html")) #f #f) + => #("file" #f "" #f #t (#("foo:") #("abc") #("def.html")) () #f) (string->url/vec "file://c:/abc/def.html") - => #("file" #f "" #f #t (#("c:") #("abc") #("def.html")) #f #f) + => #("file" #f "" #f #t (#("c:") #("abc") #("def.html")) () #f) (string->url/vec "file:\\\\d\\c\\abc\\def.html") - => #("file" #f "" #f #t (#("") #("d") #("c") #("abc") #("def.html")) #f #f))) + => #("file" #f "" #f #t (#("") #("d") #("c") #("abc") #("def.html")) () #f))) (parameterize ([file-url-path-convention-type 'unix]) ;; but no effect on http://foo:/... (test (string->url/vec "http://foo:/abc/def.html") - => #("http" #f "foo" #f #t (#("abc") #("def.html")) #f #f))) + => #("http" #f "foo" #f #t (#("abc") #("def.html")) () #f))) (parameterize ([file-url-path-convention-type 'windows]) (test (string->url/vec "http://foo:/abc/def.html") - => #("http" #f "foo" #f #t (#("abc") #("def.html")) #f #f))) + => #("http" #f "foo" #f #t (#("abc") #("def.html")) () #f))) (test (url->string (path->url (bytes->path #"c:\\a\\b" 'windows))) => "file:///c:/a/b" @@ -228,7 +228,7 @@ "HTTP://ROBBY@WWW.DRSCHEME.ORG:80/INDEX.HTML;XXX?T=P#YYY") => #("http" "ROBBY" "www.drscheme.org" 80 #t (#("INDEX.HTML" "XXX")) ((T . "P")) "YYY")) - (test-s->u #("mailto" #f #f #f #f (#("robby@racket-lang.org")) #f #f) + (test-s->u #("mailto" #f #f #f #f (#("robby@racket-lang.org")) () #f) "mailto:robby@racket-lang.org") (test (string->url/vec "http://www.drscheme.org?bar=馨慧") @@ -238,7 +238,7 @@ => #("http" #f "www.drscheme.org" #f #f () ((bár . "é")) #f)) (test-c-u/r "http://www.drscheme.org" - (make-url #f #f #f #f #f '() #f #f) + (make-url #f #f #f #f #f '() '() #f) "http://www.drscheme.org") (test-c-u/r "http://www.drscheme.org" @@ -351,11 +351,6 @@ )) - ;; PR 10497 - (test - (url->string (url #f #f #f #f #f empty empty #f)) => "?" - (url->string (url #f #f #f #f #f empty #f #f)) => "") - ) (provide tests)