http://www.perlmonks.org?node_id=1060630

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

Replies are listed 'Best First'.
Re: How to use cgi param() to read unescaped url parameters
by Your Mother (Archbishop) 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 marinersk (Priest) 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 readmoretag 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 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).

A reply falls below the community's threshold of quality. You may see it by logging in.