Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

From "C" to Rebol: - decode-cgi-special

 [1/1] from: arolls::bigpond::net::au at: 3-Aug-2001 14:30


I suggest modifying the decode-cgi function. I changed the 'equate rule to look like the 'value rule just below it. Of course, you won't be able to make an object out of it, since some of the names might have spaces in them, but for that you can still use decode-cgi. See code below, which I haven't tried.
> Hey Joe: > Unfortunately, you caught me with a number of things on my
<<quoted lines omitted: 24>>
> ; BTW: However, I believe I see the solution for my original question in > ; the mezzanine code:
decode-cgi-special: 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 "=" "=" (append list rejoin [form dehex plus-to-space name ":"] ; <- different!! ) 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 ] and a quick test: decode-cgi-special {fe+e=eenie&fi+e=meenie&foe=miney&fum=moe} == ["fe e:" "eenie" "fi e:" "meenie" "foe:" "miney" "fum:" "moe"]

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted