diff --git a/collects/net/uri-codec-unit.ss b/collects/net/uri-codec-unit.ss index f848ec3..e7d77bc 100644 --- a/collects/net/uri-codec-unit.ss +++ b/collects/net/uri-codec-unit.ss @@ -55,7 +55,7 @@ ;; 2. The control names/values are listed in the order they appear ;; in the document. The name is separated from the value by `=' and -;; name/value pairs are separated from each other by `&'. +;; name/value pairs are separated from each other by `&' or by `;'. ;; NB: RFC 2396 supersedes RFC 1738. @@ -200,21 +200,9 @@ (define (form-urlencoded-decode str) (decode form-urlencoded-decoding-vector str)) - ;; listof (cons string string) -> string + ;; listof (cons symbol string) -> string ;; http://www.w3.org/TR/html401/appendix/notes.html#ampersands-in-uris (define alist->form-urlencoded - (match-lambda - [() ""] - [((name . value)) - (string-append (form-urlencoded-encode name) - "=" - (form-urlencoded-encode value))] - [((name . value) . rest) - (string-append (form-urlencoded-encode name) - "=" - (form-urlencoded-encode value) - ";" - (alist->form-urlencoded rest))])) (lambda (args) (let* ([format-one (lambda (arg) @@ -229,11 +217,13 @@ [(null? args) null] [(null? (cdr args)) (list (format-one (car args)))] [else (list* (format-one (car args)) + ;; As per the defacto CGI standard, and + ;; HTML 4.01 ";" (loop (cdr args)))]))]) (apply string-append strs)))) - ;; string -> listof (cons string string) + ;; string -> listof (cons string string) ;; http://www.w3.org/TR/html401/appendix/notes.html#ampersands-in-uris (define (form-urlencoded->alist str) (define key-regexp (regexp "[^=]*"))