Operating System - OpenVMS
1748225 Members
4635 Online
108759 Solutions
New Discussion юеВ

Re: URL decoding in DCL with Apache

 
SOLVED
Go to solution
Stephen Eickhoff_1
Frequent Advisor

URL decoding in DCL with Apache

Has anyone put together a script to decode URLs in forms for DCL? I will be doing this with both GET and POST methods. I know Hoff has an example in his/Paul A.'s book, but I can't get a copy.
12 REPLIES 12
Hoff
Honored Contributor

Re: URL decoding in DCL with Apache

Having done this in DCL, I'd not suggest this in DCL. I'd use perl or php or some other language specifically suited for this task. It's just easier, as these languages have readily available and these languages also have battle-hardened URL decoding support.

That written, a simple URL decode routine is probably a hundred lines of DCL; it's not a big deal.

If there are no other responses or pointers posted here, I'll post up some URL code in a week or so (depending on other project and other scheduled work), over at the HL site. (I've previously posted a basic DCL CGI topic, and forms- and URL-work would be a logical extension.)

The status of the DCL book is murky; I've not received a release or a notification from DP, indicating they're now done with it. But it's out of print.
Stephen Eickhoff_1
Frequent Advisor

Re: URL decoding in DCL with Apache

Thanks, Hoff. The PHP with CSWS is based on 4.3.10 and therefore woefully out of date; but then, properly written perl looks like line noise so I think I'll start learning PHP instead. My plan was to get this very, very small site deployed with DCL and port over to PHP or perl.

I've seen code examples for perl that are about ten lines. Why does it take 100 in DCL?
Steven Schweda
Honored Contributor

Re: URL decoding in DCL with Apache

Can you give an example of what you mean by
"decode URLs"?
Hoff
Honored Contributor

Re: URL decoding in DCL with Apache

I'm assuming the question is around processing URL-encoded text. The ampersand-encoded parameters used during form submission.

And the reason it takes about a hundred lines is because DCL doesn't have a call-out capability, nor CGI-related extensions nor a library facility. So you roll explicit code in DCL, or you call into an executable image written in a compiled language, or you use perl or php or such.

Yes, php 4.3.10 is out-of-date. DCL itself is older.

The VAMP site doesn't look to be reachable, and I don't know if that's transient or permanent condition. On various other platforms, the xAMP sites have a packaged download containing all the giblets -- this for the platforms that don't have the xAMP giblets built into the base distro.

For some details on URL encoding, see
http://en.wikipedia.org/wiki/Percent-encoding
and a small herd of RFCs.
Steven Schweda
Honored Contributor

Re: URL decoding in DCL with Apache

> I'm assuming [...]

I've watched "Desk Set" enough times to have
the phrase "never assume" well implanted in
my head.

I also wrote (4-DEC-2003) a DCL procedure to
handle a short test form when I was fooling
around with CGI, and an even simpler
procedure which I use to interpret the more
complexly coded stuff I see in my Web server
log. Some of this might be useful to the
original questioner, but I can't tell from
his question what he really wants.
Bojan Nemec
Honored Contributor
Solution

Re: URL decoding in DCL with Apache

Stephen,

If you mean decoding extract parameters from the url I wrote a small procedure to do this:

$ url="http://test?a=1%44&b=x%21%23x&c="
$ query = f$element (1,"?",url)
$ if query.eqs."?" then goto done
$ paramidx = 0
$param_loop:
$ param=f$element (paramidx , "&" , query)
$ if param.eqs."&" then goto done
$ paramname=f$element (0,"=",param)
$ paramvalue=f$element (1,"=",param)
$ call decode "''paramname'" "pn"
$ call decode "''paramvalue'" "pv"
$! now you have the parameter name in the symbol PN
$! and the value in PV
$! substitute the next two lines with your code
$ write sys$output paramname,"=",paramvalue
$ write sys$output pn,"=",pv
$ paramidx = paramidx + 1
$ goto param_loop
$done:
$ exit
$decode: subroutine
$ val=""
$ rest=p1
$decodeloop:
$ part=f$element (0 , "%" , rest)
$ if part.eqs."%".or.part.eqs.rest
$ then
$ val = val + rest
$ 'p2'==val
$ exit
$ else
$ rest = f$extract (f$length(part) + 1, f$length(rest) , rest)
$ xn = f$extract (0,2,rest)
$ c[0,8] = %x'xn'
$ val = val + part + c
$ rest = f$extract (2,f$length(rest),rest)
$ endif
$ goto decodeloop
$ endsubroutine

It was not tested but you can see how to handle it. Also + signs are not converted to spaces!

Bojan
Stephen Eickhoff_1
Frequent Advisor

Re: URL decoding in DCL with Apache

I was looking for a method to decode the "URL encoding" used when forms are submitted, i.e. "%21" for "!". I had already figured out how to use f$element to split the variables, but I didn't realize that the URL encoding followed the ASCII table and that I could use binary substitution to insert the character. I got impatient and managed to put together something similar to Bojan's example about an hour before he posted it. Thanks everyone!
Willem Grooters
Honored Contributor

Re: URL decoding in DCL with Apache

The full URL (that is: what's after the server name) can be found in environment variable URI_REQUEST. Next to do is get all elements out of this using F$ELEMENT with delimiter "/" - but you'll need to know the expected URL to get the right strating point.
After that, any part that could hold encoded chracaters could be examined and altered.

(Altered real-life) exmaple:

URL: http://server/cgi-bin/gateway/vxxx/1000/something?data1$data2"
or


Apache delivers to CGI-script:

URI_REQUEST="/cgi-bin/gateway/vxxx/1000/something?data1&data2"

For this situation, the part after "gateway" is of interest, so extraction starts at poistion2:

Vrs = f$element(2, "/",URI_REQUEST)
Adm = f$element(3, "/",URI_REQUEST)
Do = f$element(4, "/",URI_REQUEST)

and symbol Do is then further processed, in this case by the program that is started, but you can use any method.
Willem Grooters
OpenVMS Developer & System Manager
Willem Grooters
Honored Contributor

Re: URL decoding in DCL with Apache

IIRC, There is a utility CGIUTL that will do some of the work. It originates from WASD but might work for SWS as well. I;m not sure it is still fully available, I didn'tsee it on the regular WASD page but it is in the archives. (I have used the CGILIB library that is part of this uitility successfully with images running under SWS (and WASD and OSU) so ith might solve part of your problem)
Willem Grooters
OpenVMS Developer & System Manager