[REBOL] Re: decode-cgi bug (?)
From: warp:reboot:ch at: 9-Feb-2004 23:36
Hi Hallvard;
this one work on your url, it also has some enhancement
most preferred is ability to set a: "" when http://dom.com?a
I'm not sure who is the author but thanks, and shouldn't this version
replace
rebol's one?
Hope that helps and have a great day!
Will Arp
[warp--reboot--ch]
;core 2.6 decode-cgi do not accept "a" only "a=" or "a&"
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 name-chars val add-nv
] [
add-nv: func [ list name value /local val-ptr ] [
value: either none? value
[ copy "" ]
[ form dehex (replace/all value "+" " ") ]
either none? val-ptr: find list to-set-word name [
append list compose [ (to-set-word name) (value) ]
] [
idx: index? next val-ptr
poke list idx compose [ (pick list idx) (value) ]
]
]
list: make block! 8
name-chars: complement charset "&="
equate: [ copy name some name-chars value ]
value: [ "=" value
| "&" (add-nv list name "")
| [copy val to "&" "&" | copy val to end]
(add-nv list name val)
]
parse/all args [ some equate | none ]
list
]
On 9-feb-04, at 23:07, Hallvard Ystad wrote: