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

sending 'none to CGI

 [1/3] from: al::bri::xtra::co::nz at: 11-Jan-2001 15:35


> If I send the following text/html output to the user > > {<A HREF="http://www.domain.dom/cgi-bin/script.cgi?value=} none {>} > > and he or she clicks on the resultant link, what value will be passed to
CGI? Will it be a 'none value REBOL can understand? I suspect that it will be a unevaluated word, like 'none in a block: [none] Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [2/3] from: sterling:rebol at: 10-Jan-2001 19:18


It will arrive as a string and remain that way until you change it. REBOL, when run in CGI mode, gathers up the relevant environment variables and drops them into the system/options/cgi object. The query-string holds the exact text following the '?' in the URL. You can then make use of 'decode-cgi to make checking values easier: system/options/cgi/query-string: "value=none" cgi-obj: make object! decode-cgi system/options/cgi/query-string The cgi-obj will now be an object containing the word 'value which has the value of the string "none". REBOL purposely does not evaluate any of the CGI information as that would open a security hole. In order to change that "none" into a REBOL none value, you would need to use load. load "none" will result in a REBOL none value. However, if your query string looked like this: value=none none then the resulting decoded string would be: none none and loading it would result in a block: [none none] which, as you point out below is a block with unevaluated words which means that neither item in the block is actually the REBOL none value. They are both simply the word 'none. It is best, when writing REBOL CGI applications, to know ahead of time what kind of data you are expecting to receive. You can then use 'make object decode-cgi' to help you make an object with the values. Then, for non-string values, either wrap a direct conversion in a try block: if error? try [to-integer cgi-obj/usernumber] ["return error page"] or check the type of a load (which is safe because it does not evaluate any code): if not integer? load cgi-obj/usernumber ["return error page"] Well, that was rather long-winded for a one line answer. Sorry. Sterling

 [3/3] from: rchristiansen:pop:isdfa:sei-it at: 10-Jan-2001 13:01


If I send the following text/html output to the user {<A HREF="http://www.domain.dom/cgi-bin/script.cgi?value=} none {>} and he or she clicks on the resultant link, what value will be passed to CGI? Will it be a 'none value REBOL can understand? Using the console, the results seems to be correct.
>> print (rejoin [{<A HREF="http://www.domain.dom/cgi-bin/script.cgi?value=} none {>} ])
<A HREF="http://www.domain.dom/cgi-bin/script.cgi?value=none> -Ryan