Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

How to use cgi param() to read unescaped url parameters

by invader7 (Initiate)
on Oct 31, 2013 at 19:50 UTC ( #1060630=perlquestion: print w/ replies, xml ) Need Help??
invader7 has asked for the wisdom of the Perl Monks concerning the following question:

Hello , im trying to read parameters from my url at file test with param('foo') but my url is http://test/test?file=test%3bfoo=2848 instead http://test/test?file=test;foo=2848 how can i make it work either ? thanks !!

Comment on How to use cgi param() to read unescaped url parameters
Re: How to use cgi param() to read unescaped url parameters
by marinersk (Chaplain) on Oct 31, 2013 at 20:19 UTC
    Update: Modified nearly wholesale given understanding granted by other posts

    So, tests done on a generic Perl CGI engine:

    http://bhmk.com/cgi-bin/testcgiparm.pl?file=test%3bfoo=2848
          Parameter    Value
    file test;foo=2848

    http://bhmk.com/cgi-bin/testcgiparm.pl?file=test;foo=2848
          Parameter    Value
    file test
    foo 2848

    http://bhmk.com/cgi-bin/testcgiparm.pl?file=test&foo=2848
          Parameter    Value
    file test
    foo 2848

    http://bhmk.com/cgi-bin/testcgiparm.pl?file=test\;foo=2848
          Parameter    Value
    file test\
    foo 2848

    So I'm afraid I don't understand the problem.

    • The first technique is probably not what you were looking for.
    • The second technique seems to work for me -- this was unexpected prior to reading the updates below.
    • The third example is probably what you are looking for.
    • The fourth example was just to see what would happen. I suppose I should have been able to predict it but I didn't.

    The CGI script which generated this these results is behind the readmore tag below.

      My problem is that i send an email with this link : http://bhmk.com/cgi-bin/testcgiparm.pl?file=test;foo=2848 When i open the mail at thunderbird it works, when i open the mail at hotmail (chrome) it makes it http://bhmk.com/cgi-bin/testcgiparm.pl?file=test%3bfoo=2848 and then it doesn't work !!
        Just for kicks, try sending it with the ampersand instead of the semicolon and see what happens.
Re: How to use cgi param() to read unescaped url parameters
by keszler (Priest) on Oct 31, 2013 at 20:27 UTC
    If I understand the question correctly, the answer is to replace the '%3b' or ';' in the URL with '&'.

    This works with marinersk's URL above: (ampersand instead)

      Ah! And the light goes on! I think you've sussed it; I think I may have completely misread the question.

      I will update the above post to show before-and-after results.

Re: How to use cgi param() to read unescaped url parameters
by Your Mother (Canon) on Oct 31, 2013 at 21:07 UTC

    You should not make it work either way. ";" is a legal separator and if it's escaped, it's meant to be the literal character; not a super secret non-standard, literal semi-colons are now impossible, version. You should fix the code that is creating the broken URI, not create code that allows broken ones to work, because they shouldn't.

    We'd love to help fix the real problem if you can show the URL generating code.

      Oh, you are so getting a ++ tomorrow.
Re: How to use cgi param() to read unescaped url parameters
by sundialsvc4 (Abbot) on Nov 01, 2013 at 00:55 UTC
    Beat ya to it.   I still have upvotes left.
      The OP asked a question, and it wasn't about upvotes or beatings sundialsvc4
Re: How to use cgi param() to read unescaped url parameters
by invader7 (Initiate) on Nov 01, 2013 at 12:00 UTC
    My problem is that i send an email with this link : http://bhmk.com/cgi-bin/testcgiparm.pl?file=test;foo=2848 When i open the mail at thunderbird it works, when i open the mail at hotmail (chrome) it makes it http://bhmk.com/cgi-bin/testcgiparm.pl?file=test%3bfoo=2848 and then it doesn't work !!

      Seriously? Even after a decade of IE 6 it’s hard to believe MSFT is that incompetent / shows such poor judgement… If it's true and it's not Thunderbird overcompensating then probably all you can do is move from ; to &. They are equivalent in the spec though I prefer semi-colons because they are four characters shorter when typing HTML -> ; vs & (proper spelling of & in HTML).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1060630]
Approved by marinersk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-12-23 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (135 votes), past polls