[Nh-pm] Oddity with URI::Escape

Ray Cote rgacote at AppropriateSolutions.com
Mon Jan 31 08:55:02 PST 2005


I must be missing something here...

While building an HTTP query string, I'm escaping the data being 
passed in the query portion.

For example, I need to turn the following:
   http://www.example.com/?company=A&B Jones+1
into:
   http://www.example.com?company=A%26B%20Jones%2B1

The &, +, and space are all escaped.

Now, when I run the following test code on our Linux box:
#include URI::Escape;
print 'A&B Jones+1';

I get:
A%26B%20Jones%2B1

When I run the same thing on any of our Windows machines, I get:
A&B%20Jones+1

If I look at the URI::Escape.pm module (v3.13 1999/03/20 gisle) I see 
a default $escapes string built containing hex representations of all 
the character values from 0 thru 255.

The uri_escape subroutine in escape.pm checks to see if a pattern is 
being passed in (I'm not) and, if there is no pattern, it moves to 
the section of code where a regular expression translates the 
"Default unsafe characters."

If I look in the substitution string, I most definitely see the '&' character.
So it should be substituted. But it is not!

I've now run this on two different Windows boxes.
I'm obviously missing something.
Any ideas as to what?

As a side note, the Python encoding routines are working just fine on 
those Windows machines.

-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.com


More information about the Nh-pm mailing list