changed default current-alist-separator-mode to amp, added semi-or-amp mode
svn: r7057 original commit: 0e2a1a465ac5bb8d0e5a67ed115e584e0faef1e9
This commit is contained in:
parent
9f656deb25
commit
73be59b627
|
@ -1,97 +1,15 @@
|
|||
;; 1/2/2006: Added a mapping for uri path segments
|
||||
;; that allows more characters to remain decoded
|
||||
;; -robby
|
||||
|
||||
|
||||
#|
|
||||
|
||||
People often seem to wonder why semicolons are the default in this code,
|
||||
and not ampersands. Here's are the best answers we have:
|
||||
People used to wonder why semicolons were the default. We then
|
||||
decided to switch the default back to ampersands --
|
||||
|
||||
From: Doug Orleans <dougorleans@gmail.com>
|
||||
To: plt-scheme@list.cs.brown.edu
|
||||
Subject: Re: [plt-scheme] Problem fetching a URL
|
||||
Date: Wed, 11 Oct 2006 16:18:40 -0400
|
||||
X-Mailer: VM 7.19 under 21.4 (patch 19) "Constant Variable" XEmacs Lucid
|
||||
http://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2
|
||||
|
||||
Robby Findler writes:
|
||||
> Do you (or does anyone else) have a reference to an rfc or similar that
|
||||
> actually says what the syntax for queries is supposed to be?
|
||||
> rfc3986.txt (the latest url syntax rfc I know of) doesn't seem to say.
|
||||
We recommend that HTTP server implementors, and in particular, CGI
|
||||
implementors support the use of ";" in place of "&" to save authors
|
||||
the trouble of escaping "&" characters in this manner.
|
||||
|
||||
The HTML 4.01 spec defines the MIME type application/x-www-form-urlencoded:
|
||||
|
||||
http://www.w3.org/TR/html401/interact/forms.html#form-content-type
|
||||
|
||||
See also XForms, which uses a "separator" attribute whose default
|
||||
value is a semicolon:
|
||||
|
||||
http://www.w3.org/TR/xforms/slice11.html#serialize-urlencode
|
||||
http://www.w3.org/TR/xforms/slice3.html#structure-model-submission
|
||||
|
||||
--dougorleans@gmail.com
|
||||
_________________________________________________
|
||||
For list-related administrative tasks:
|
||||
http://list.cs.brown.edu/mailman/listinfo/plt-scheme
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
From: John David Stone <stone@math.grinnell.edu>
|
||||
To: plt-scheme@list.cs.brown.edu
|
||||
Subject: Re: [plt-scheme] Problem fetching a URL
|
||||
Date: Wed, 11 Oct 2006 11:36:14 -0500
|
||||
X-Mailer: VM 7.19 under Emacs 21.4.1
|
||||
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
Danny Yoo:
|
||||
|
||||
> > Just out of curiosity, why is current-alist-separator-mode using
|
||||
> > semicolons by default rather than ampersands? I understand that
|
||||
> > flexibility is nice, but this is the fifth time I've seen people hit this
|
||||
> > as a roadblock; shouldn't the default be what's most commonly used?
|
||||
|
||||
Robby Findler:
|
||||
|
||||
> It is my understanding that semi-colons are more standards compliant.
|
||||
> That's why it is the default.
|
||||
|
||||
According to the RFC1738 (http://www.ietf.org/rfc/rfc1738.txt),
|
||||
semicolons and ampersands are equally acceptable in URLs that begin with
|
||||
`http://' (section 5, page 17), but semicolons are ``reserved'' characters
|
||||
(section 3.3, page 8) and so are allowed to appear unencoded in the URL
|
||||
(section 2.2, page 3), whereas ampersands are not reserved in such URLs and
|
||||
so must be encoded (as, say, &). RFC2141
|
||||
(http://www.ietf.org/rfc/rfc2141.txt) extends this rule to Uniform Resource
|
||||
Names generally, classifying ampersands as ``excluded'' characters that
|
||||
must be encoded whenever used in URNs (section 2.4, page 3).
|
||||
|
||||
The explanation and rationale is given in Appendix B
|
||||
(``Performance, implementation, and design notes,''
|
||||
http://www.w3.org/TR/html401/appendix/notes.html) of the World Wide Web
|
||||
Consortium's technical report defining HTML 4.01. Section B.2.2
|
||||
(``Ampersands in URI attribute values'') of that appendix notes that the
|
||||
use of ampersands in URLs to carry information derived from forms is, in
|
||||
practice, a serious glitch and source of errors, since it tempts careless
|
||||
implementers and authors of HTML documents to insert those ampersands in
|
||||
URLs without encoding them. This practice conflicts with the simple and
|
||||
otherwise standard convention, derived from SGML, that an ampersand is
|
||||
always the opening delimiter of a character entity reference. So the World
|
||||
Wide Web Consortium encourages implementers to use and recognize semicolons
|
||||
rather than ampersands in URLs that carry information derived from forms.
|
||||
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.5 (GNU/Linux)
|
||||
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>
|
||||
|
||||
iD4DBQFFLR16bBGsCPR0ElQRAizVAJddgT63LKc6UWqRyHh57aqWjSXGAJ4wyseS
|
||||
JALQefhDMCATcl2/bZL0bw==
|
||||
=W2uS
|
||||
-----END PGP SIGNATURE-----
|
||||
See more in PR8831.
|
||||
|
||||
|#
|
||||
|
||||
|
@ -305,7 +223,8 @@ JALQefhDMCATcl2/bZL0bw==
|
|||
;; http://www.w3.org/TR/html401/appendix/notes.html#ampersands-in-uris
|
||||
;; listof (cons symbol string) -> string
|
||||
(define (alist->form-urlencoded args)
|
||||
(let* ([sep (if (eq? (current-alist-separator-mode) 'amp) "&" ";")]
|
||||
(let* ([sep (if (memq (current-alist-separator-mode) '(semi semi-or-amp))
|
||||
";" "&")]
|
||||
[format-one
|
||||
(lambda (arg)
|
||||
(let* ([name (car arg)]
|
||||
|
@ -341,11 +260,11 @@ JALQefhDMCATcl2/bZL0bw==
|
|||
|
||||
(define current-alist-separator-mode
|
||||
(make-parameter 'amp-or-semi
|
||||
(lambda (s)
|
||||
(unless (memq s '(amp semi amp-or-semi))
|
||||
(raise-type-error 'current-alist-separator-mode
|
||||
"'amp, 'semi, or 'amp-or-semi"
|
||||
s))
|
||||
s))))
|
||||
(lambda (s)
|
||||
(unless (memq s '(amp semi amp-or-semi semi-or-amp))
|
||||
(raise-type-error 'current-alist-separator-mode
|
||||
"'amp, 'semi, 'amp-or-semi, or 'semi-or-amp"
|
||||
s))
|
||||
s))))
|
||||
|
||||
;;; uri-codec-unit.ss ends here
|
||||
|
|
Loading…
Reference in New Issue
Block a user