Python's CGI and Javascripts uriEncode: A disconnect.

Erik Max Francis max at alcyone.com
Sat Jul 5 16:08:48 EDT 2003


Andrew Clover wrote:

> This is part of the specification for the media type
> application/x-www-form-urlencoded, defined by HTML itself (section
> 17.13.4.1 of the 4.01 spec). This states that spaces should normally
> be encoded as '+', however really using '%20' is just as good and
> causes less confusion, so that's what newer browsers (and I) do.
> 
> Elsewhere, spaces should not be encoded as '+'.

Right.  As part of the query string, + for space is fine.  Elsewhere in
the URL, it is not.

> The reasoning for this initial decision is unclear - presumably it is
> intended to improve readability, but URIs with query parts are
> generally not going to be very readable anyway.

Well, an obvious reason would be that + is a perfectly legal character
in many filesystems, as is a space.

Actual spaces in URIs are illegal; they should be replaced with either
%20 or + (depending where in the URI they appear).  Probably he's
encountering frustrating bugs in some browsers where it doesn't bother
replacing spaces with the proper equivalent so that they will be
well-formed URIs.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Life imitates art far more than art imitates life.
\__/  Oscar Wilde




More information about the Python-list mailing list