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

Re: Re: CGI fails to urlencode & chars in outbound url's

by Juerd (Abbot)
on Jun 12, 2002 at 16:10 UTC ( [id://173895]=note: print w/replies, xml ) Need Help??


in reply to Re: CGI fails to urlencode & chars in outbound url's
in thread CGI fails to urlencode & chars in outbound url's

You also may use CGI.pm's own escape function:

This is probably irrelevant to this discussion. The a() function is being used, which already escapes its arguments. Or at least CGI.pm version 2.752 does.

2;0 juerd@ouranos:~$ perl -MCGI=a -le'print a({ -href => "&&&" }, "asd +f")' <a href="&amp;&amp;&amp;">asdf</a>

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
Re: Re: Re: CGI fails to urlencode & chars in outbound url's
by projekt21 (Friar) on Jun 12, 2002 at 16:27 UTC

    But that's exactly what nobody wants, as the & of &amp; is treated as parameter delimiter.

    #!/usr/bin/perl -w use strict; use CGI; my $q = new CGI; print $q->header; print "<pre>\n"; print $_, "=", $q->param($_), "\n" for $q->param; print "\n</pre>\n";
    prints
    foo=bar amp= baz=
    for
    http://electra.igd.fhg.de/cgi-bin/test3.pl?foo=bar&amp;baz
    but it should print
    foo=bar&baz
    You need to use CGI::escape or URI::Escape but not CGI::escapeHTML.

    Update: Just for completeness: a() calls CGI::Util::make_attributes on each attribute, the latter calls CGI::Util::simple_escape for escaping ("&"->"&amp;" and some others). CGI::Util::escape does something different (see my last post).

    alex pleiner <alex@zeitform.de>
    zeitform Internet Dienste

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-19 05:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found