Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL escaping 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hello,

I'm not sure where to post this question, but here goes anyway.

I have a PERL program that needs to log into a 3rd party system, their API required me to post a URL encoded XML doc.

That isn't the problem, however the users password has a (+) plus sign in it, isn't this a problem, or if I use the URI module, does it get converted to something and then converted back to a plus sign their end.

I seem to recall that if a URL has a + in it, it is converted to a ( ) Space! when STDIN is parsed.

Is that correct? and therefor is having a (+) in the URL encoded data a problem.

thanks
1dmf

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
If it's being escaped correctly, your plus sign should be encoded as %2B. This will be converted back when unencoding.

Whether it's a problem or not really depends on how you're constructing the URL in the first place.
 
the URL is a URI escaped XML doc so it has a tag..
<user_password>my+pass</user_password>, which I build the full XML doc into a string and then URI::escape it, then send that to the URL for processing.

So the + will be turned into %2B via URI::escape, but I take it all URL's when parsed, whether handrolled or via CGI will always change + to space before using pack(hex) to change the % symbols back to normal characters, so therefore the + will not be turned into a space.

Is that correct?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Exactly:
Code:
#!/usr/bin/perl -w
use strict;
use CGI;
use URI::Escape;

my $var = "fdasfads+fdasfas";

my $q = new CGI( 'blah=' . uri_escape( $var ) );

print $q->param( 'blah' ),"\n";
 
Great thanks Ishnid, at least I know that isn't the problem with it no working - lol

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top