[REBOL] Re: decode-cgi bug (imbedded spaces in names)
From: andreas:bolka:gmx at: 10-Feb-2004 15:44
Tuesday, February 10, 2004, 12:47:11 AM, Tim wrote:
> I want to note that I modified decode-cgi so that a block of string
> pairs is returned rather than a block of alternating to-set-word
> types and strings.
> Reason for it: A rebol cgi program might be processing a form in
> which field names have imbedded spaces.
I think that it will be rather hard to get that kind of data to a CGI
in real world scenarios. You won't be able to pass it via method GET's
query string, as a blank is not a valid character there. So your url
will either look like http://foo/bar?first one=1 or like
http://foo/bar?first+one=1.
Quite the same holds for method POST. If you submit a 'input
type="text" name="first one"' with a value of "1" a browser will send
'first+one=1' as entity body.
However, if one _manually_ does a POST this kind of bad data is
certainly possible. For example
read/custom http://foo/bar [ post "first one=1" ]
will send 'first one=1' as entity body.
So, what's the point of those lengthy explanations? While this is a
scenario that is only created by 'broken' tools, 'decode-cgi should
certainly cope with this broken data.
Incidentially, my patched version of decode-cgi does _somehow_ cope
with it:
>> o: make object! b: decode-cgi "field one=1&fieldtwo=2"
>> probe o
make object! [
field one: "1"
fieldtwo: "2"
]
>> print mold b
[field one: "1" fieldtwo: "2"]
>> get in o to-word "field one"
== "1"
--
Best regards,
Andreas