Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: CGI Input with Escaped Characters

by shmem (Chancellor)
on Apr 02, 2017 at 09:17 UTC ( [id://1186705]=note: print w/replies, xml ) Need Help??


in reply to CGI Input with Escaped Characters

If it is a GET query, then the original data should be in $ENV{QUERY_STRING} iirc.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: CGI Input with Escaped Characters
by hoyt (Acolyte) on Apr 02, 2017 at 16:51 UTC
    That looks correct, and may work, but I try to keep the Perl code so that it'll work from command line too for troubleshooting. When I output the $ENV{} from command line, it doesn't show to that as an available key. Would that only work from a web posting action? Thanks!

      You can pass CGI parameters on the command, using data=foo api_key=1234. See the DEBUGGING section of CGI. But I doubt that CGI will shoehorn that back into %ENV.

      You could set the environment variable on the command line also

      $ env QUERY_STRING=data=foo&api_key=laurel%26hardy script.cgi

      or you could check inside your script if it is run from the commandline:

      if (-t STDIN) { # command line. for params, substitute special chars (e.g. & => %2 +6) # (there must be a module out there which does that for you) } else { # via webserver }
      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1186705]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-23 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found