Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: CGI.pm problems

by Illiad (Initiate)
on Dec 14, 2001 at 04:07 UTC ( [id://131844]=note: print w/replies, xml ) Need Help??


in reply to CGI.pm problems

Rather simple reason that CGI.pm isn't doing what you'd like it to:

Your incomming XML is likely unquoted.

Let's assume you're trying to pass in this small XML string (I'll do the example in GET, since CGI.pm handles GET and POST transparantly): "<xmltag>Tulips &amp; Flowers<xmltag>".

in a get request this is going to look like:
script.pl?xml=<xmltag>Tulips &amp; Flowers<xmltag>

Ick! Since you haven't followed the specs for escapeing URLs, it's going to get nasty.

Get the people who are sending your request to properly escape the data:

my $newval = CGI::escape(qq("<xmltag>tulips &amp; Flowers:</xmltag>));
$newval will now look more like: %3Cxmltag%3Etulips%20%26amp%3B%20Flowers%3A%3C%2Fxmltag%3E

Which is how it should look if you're following the standards for URL quoting.

Now, using CGI.pm:

use CGI.pm my $q = new CGI; my $xml = CGI::unescape($q->param('xml'));

Voila!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-03-29 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found