[REBOL] Re: Inconsistent CGI decoding behaviour
From: ryanc:iesco-dms at: 21-Jan-2002 12:10
Hey Hallvard,
In my opinion "garbage in, garbage out." But since the issue
seemed so straight forward, I could'nt resist making the
fix.
decode-cgi: func [
{Converts CGI argument string to a list of words and
value strings.}
args [any-string!] "Starts at first argument word"
/local list equate value name val plus-to-space
][
plus-to-space: func [arg /local seek chr] [
if any [none? arg empty? arg] [return ""]
seek: arg
while [seek: find seek #"+"] [
change seek #" "
seek: next seek
]
head arg
]
list: make block! 8
equate: [copy name to "=" "=" (if name [append list
to-set-word name]) value]
value: ["&" (append list copy "") | [copy val to "&" "&"
| copy val to end
]
(append list either none? val [copy ""] [form dehex
plus-to-space val]
)]
parse/all args [some equate | none]
list
]
>> probe make object! probe decode-cgi "t=1&=ff"
[t: "1" "ff"]
make object! [
t: "1"
]
>>
This I will leave it up to you to test it and submit to
feedback.
--Ryan