Changeset 20244 in project


Ignore:
Timestamp:
09/11/10 17:12:02 (10 years ago)
Author:
sjamaan
Message:

Fix #373 (query alists encoded according to x-www-form-urlencoded rather than www-form-urlencoded)

Location:
release/4/uri-common/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/uri-common/trunk/tests/run.scm

    r18959 r20244  
    8585(define update-cases
    8686  `(("query" query:
    87      ("" ((foo . "bar?qux")) "?foo=bar?qux")
    88      ("" ((foo?bar . "qux")) "?foo?bar=qux")
     87     ;; www-form-urlencoded (hoehrmann):
     88     ;; ("" ((foo . "bar?qux")) "?foo=bar?qux")
     89     ;; ("" ((foo?bar . "qux")) "?foo?bar=qux")
     90     ;; x-www-form-urlencoded:
     91     ("" ((foo . "bar?qux")) "?foo=bar%3Fqux")
     92     ("" ((foo?bar . "qux")) "?foo%3Fbar=qux")
    8993     ("" ((foo . "bar&qux")) "?foo=bar%26qux")
    9094     ("" ((foo&bar . "qux")) "?foo%26bar=qux")
     
    148152     )
    149153    (((Cipher . "c=(m^e)%n"))
    150      "Cipher=c%3D(m%5Ee)%25n"
     154     ;; www-form-urlencoded (hoehrmann):
     155     ;; "Cipher=c%3D(m%5Ee)%25n"
     156     ;; x-www-form-urlencoded:
     157     "Cipher=c%3D%28m%5Ee%29%25n"
    151158     "Cipher=c=(m%5Ee)%25n"
    152159     "Cipher=c=(m^e)%n"
  • release/4/uri-common/trunk/uri-common.scm

    r18959 r20244  
    237237;; (http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1)
    238238;; and XHTML XForms' specification
    239 ;; (http://www.w3.org/TR/xforms/#structure-model-submission)
     239;; (http://www.w3.org/TR/xforms/#serialize-urlencode)
    240240;;
    241241;; The latter is a more generalised form of the former, as it allows
     
    253253;; intended to standardize this, but it was allowed to expire in 2007:
    254254;; http://ietfreport.isoc.org/idref/draft-hoehrmann-urlencoded
     255;; It was different in a few ways from the x-www-form-urlencoded type.
     256;; For example, www-form-urlencoded only pct-encoded the chars that
     257;; are not allowed in a query string, whereas x-www-form-urlencoded
     258;; pct-encodes *all* reserved chars, regardless of whether it is
     259;; necessary. There are servers which do not accept input that isn't
     260;; fully pct-encoded so we use strictly x-www-form-urlencoded.
    255261
    256262(define form-urlencoded-separator (make-parameter ";&"))
     
    258264(define (form-urlencode alist #!key (separator (form-urlencoded-separator)))
    259265  (and alist (not (null? alist))
    260        (let* ((separator-chars (->char-set separator))
    261               (separator-string (string-take
    262                                  ;; Can't use separator-chars here because
    263                                  ;; charsets have no ordering and conversion
    264                                  ;; to string and back reorders the chars
     266      (let* ((separator-chars (->char-set separator))
     267             (separator-string (string-take
     268                                ;; Can't use separator-chars here because
     269                                ;; charsets have no ordering and conversion
     270                                ;; to string and back reorders the chars
    265271                                 (if (string? separator)
    266272                                     separator
     
    270276                      (generic:uri-encode-string
    271277                       s
    272                        (char-set-union separator-chars
    273                                        (char-set #\= #\+)
    274                                        (char-set-delete char-set:query/fragment
    275                                                         #\space)))
    276                       '((" " . "+")))))
     278                       (char-set-union
     279                        separator-chars
     280                        (char-set #\= #\+)
     281                        (char-set-delete
     282                         (char-set-complement generic:char-set:uri-unreserved)
     283                         #\space)))
     284                       '((" " . "+")))))
    277285              (encoded-components
    278286               (reverse (fold
Note: See TracChangeset for help on using the changeset viewer.