On Thu, Jul 05, 2001 at 06:01:58PM -0700, Jon Stevens wrote:
> > I just don't like the %2C's littering my URLs.
>
> Pick another character then. It is easy to write your own class in Turbine
> to do so. Much easier than writing it yourself from scratch.
To those who are interested in making the '%2Cs' disappear:
Yes, it's a shame that java.net.URLEncoder encodes the comma. The
URLEncoder.java source (version 1.15 98/06/29 at least) says "The list
of characters that are not encoded have been determined by referencing
O'Reilly's "HTML: The Definitive Guide" (page 164)" and also that
"convert[s] a String into a MIME format called 'x-www-form-urlencoded'".
However page 4 of RFC 1738 says that commas may be "used unencoded
within a URL". Furthermore, the application/x-www-form-urlencoded format
description in RFC 1866 doesn't mention any special treatment for
commas. Perhaps "HTML: The Definitive Guide" probably picks up on the
point that the comma is an part of the "extra" set of characters and not
part of the "safe" set of characters (who knows why the book makes this
distinction? I don't have a copy of the book to check with), though it
is not "unsafe" either and is part of the "unreserved" set, so no URL
schemes should give the comma any special meaning that requires commas
to be or not to be encoded. More convincingly, page 4 of RFC 1738 says:
The characters ";","/", "?", ":", "@", "=" and "&" are the
characters which may be reserved for special meaning within a
scheme. No other characters maybe reserved within a scheme.
Anyway, after that ramble...my solution to this (cosmetic, but
distracting) problem was to patch Turbine's TemplateLink.java so that
the toString() method calls getURI() instead of super.toString() (so
that only the getURI() method need be overridden) and then create a
subclass of TemplateLink which calls super.getURI() and replaces
occurrences of %2C and %2c by the comma verbatim and returns that
result, so that in my Velocity templates the $link tool returns pretty
URLs. Now action URLs (with dotted class names) and template URLs (with
'comma-ed' path names) look mutually congruous. However, unencoding the
encoded characters is a Bad Thing in general though it does what I want
without having to rewrite the DynamicURI class. There are probably very
few people who want to go to these lengths, but it might bring
peace-of-mind to know that it *can* be done. :)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]