Debugging on On-Rev - I don't GET it

Sarah Reichelt sarah.reichelt at gmail.com
Fri Sep 18 05:22:34 EDT 2009


On Fri, Sep 18, 2009 at 6:50 PM, Terry Vogelaar <tvogelaar at de-mare.nl> wrote:
> I don't understand how to debug an irev file when form input is involved.
>
> Here it the case:
> I want to pick data up from a CGI driven HTML page. But my irev script needs
> to do some preprocessing first.
> So I made a script "preprocess.irev" and I began to try just passing
> whatever this script GETs:
> I tried "preprocess.irev?id18=1&m=eph+1%3A1-5%3A1" with the following
> script:
> <?rev
> put $_GET into sGET
> combine sGET using "&"
> put "script.cgi?set=5&lang=en&pos=0&nobar=1&t=4&" & urlencode(sGET) into
> varZ
> put url varZ
> ?>
>
> It returned "Bad request". But when I hardcoded in exactly the same values,
> it worked:
> <?rev
> put "id18=1&m=eph+1%3A1-5%3A1"into sGET
> put "http://www.biblija.net/biblija.cgi?lang=en&set=5&pos=0&nobar=1&t=4&" &
> sGET into varZ
> put url varZ
> ?>
>
> I wanted to insert a breakpoint, but then I realized I didn't knew how to
> debug this because of the additional data in the url. Any solutions?

You can still insert a breakpoint, but instead of just clicking the
Debug button in the On-Rev client, switch to your browser and go to
the page
<http://yourname.on-rev.com:7309/preprocess.irev?id18=1&m=eph+1%3A1-5%3A1>
replacing "yourname" in the URL with your on-rev user name, or
replacing the first part of the address with your site address.

As regards fixing your script, there are a couple of problems.
Firstly, you would need to combine sGET using "&" and "=" in order to
get the correct array members.

However this doesn't really help, because then you get into a mess
with urlencoding.
The data is decoded in the $_GET array, so it needs to be urlencoded again.
But if you assemble the whole set of parameter data and urlencode it
all at once, the & and = signs gets encoded too.

So here is what I came up with, which loops through the $_GET array
and constructs the URL as it goes.

put empty into sGET
repeat for each key k in $_GET
	put "&" & k & "=" & urlencode($_GET[k]) after sGET
end repeat

put "script.cgi?set=5&lang=en&pos=0&nobar=1&t=4" & sGET into varZ
put content varZ

The "put content" line at the end is just so you can check what
happening. When you are sure that is correct, then you can change it
to "put URL".
Note that I removed the ampersand that you had at the end of the fixed
part of the URL, as I needed it be be added as part of the repeat
loop.

Cheers,
Sarah



More information about the use-livecode mailing list