Re: CGI URLs in HREFs

Arnoud (galactus@htmlhelp.com)
Sun, 13 Jul 1997 14:58:37 +0200


From: galactus@htmlhelp.com (Arnoud "Galactus" Engelfriet)
To: www-html@w3.org
Subject: Re: CGI URLs in HREFs
Date: Sun, 13 Jul 1997 14:58:37 +0200
Message-ID: <9DNyz4uYOxOD089yn@htmlhelp.com>

In article <v0310285eafee2a020172@[205.149.180.135]>,
Walter Ian Kaye <walter@natural-innovations.com> wrote:
> So, I guess I'll have to update my 'wiklib.pl' library to check for
> semicolons instead of just assuming ampersands. Now to come up with
> a good algorithm. 

My CGI library simply splits at & _or_ ;. I think this is safe, because
the & and ; characters must always be encoded if they're used as the
literal characters in the URL (RFC 1738, section 2.2 "Reserved"). A
valid query string will therefore always contain _either_ ; or &
unescaped, and then that character is the separator.

Of course, if someone manually GETs  something like
/cgi-bin/script?foo=bar;baz=quug&frop=wawa
then my script will see three arguments, yours will see two. But I'd
say the above query string is not valid, so we're both right. :-)

>   1. Count number of '='s in query string.
>   2. If more than one, determine whether '&' or ';' is used as field
>      separator:

Note that the above (invalid) query string has an equal number of ; and &
characters, so you don't know which one is correct.

-- 
E-mail: galactus@htmlhelp.com .................... PGP Key: 512/63B0E665
Maintainer of WDG's HTML reference: <http://www.htmlhelp.com/reference/>