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

As amended by RFC 2732(http://www.ietf.org/rfc/rfc2732.txt) the characters 
"[" and "]" have been added (formerly _unwise_)

There is also an _unwise_ set including "{", "}","|","\", and "`" 

On a side note, although URI::Escape properly unescapes Unicode,
it doesn't escape it (for me, with 5.6.1)

Neils Poppe recently suggested this on perl-xml for UTF-8

sub escape {
  join '', map {
    chr($_) =~ /([a-zA-Z0-9_.-])/o? $1 : sprintf "%%%02X", $_
  } unpack 'C*', shift
}




-----Original Message-----
From: Kyle Oppenheim [mailto:kyleo@;tellme.com]
Sent: Thursday, November 14, 2002 7:11 PM
To: modperl List
Subject: Re: URI escaping question


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
>


------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated 
recipient(s) named above.  If you are not the intended recipient of this message you 
are hereby notified that any review, dissemination, distribution or copying of this 
message is strictly prohibited.  This communication is for information purposes only 
and should not be regarded as an offer to sell or as a solicitation of an offer to buy 
any financial product, an official confirmation of any transaction, or as an official 
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or 
error-free.  Therefore, we do not represent that this information is complete or 
accurate and it should not be relied upon as such.  All information is subject to 
change without notice.


Reply via email to