According to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt) the reserved
characters in the query component of a URI are ";", "/", "?", ":", "@","&",
"=", "+", ",", and "$".
Apache::Util->escape_uri() does not escape ":", "@", "&", "=", "+", ",", or
"$".

Something like the following should work:

    use URI::Escape qw(uri_escape);

    sub uri_escape_query_value {
        my $character_class = '^A-Za-z0-9\-_.!~*\'()';
        uri_escape($_[0], $character_class);
    }

- Kyle

----- Original Message -----
From: "Ray Zimmerman" <[EMAIL PROTECTED]>
To: "modperl List" <[EMAIL PROTECTED]>
Cc: "Raj Chandran" <[EMAIL PROTECTED]>
Sent: Thursday, November 14, 2002 12:25 PM
Subject: URI escaping question


> Oops ... finger slipped before I was done typing ...
>
> Suppose I have a hash of string values that I want to include in the
> query string of a redirect URL. What is the accepted way of escaping
> the values to be sure that they come through intact?
>
> Specifically, it seems that Apache::Util->escape_uri() is not
> escaping '=' and '&' so if one of the values in the hash is a URI
> with a query string it messes things up.
>
> --
>   Ray Zimmerman  / e-mail: [EMAIL PROTECTED] / 428-B Phillips Hall
>    Sr Research  /   phone: (607) 255-9645  /  Cornell University
>     Associate  /      FAX: (815) 377-3932 /   Ithaca, NY  14853
>

Reply via email to