tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13969] - ':' in parameter breaks encodeURL() and encodeRedirectURL()
Date Mon, 18 Nov 2002 16:43:19 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13969>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13969

':' in parameter breaks encodeURL() and encodeRedirectURL()

Brian.Ewins@btinternet.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



------- Additional Comments From Brian.Ewins@btinternet.com  2002-11-18 16:43 -------
':' and '%' are reserved characters in the URL spec
(http://www.w3.org/Addressing/rfc1738.txt, see section 5). You need to URL
encoded them, or you'll get either a MalformedURLException or undefined behaviour.

It seems probably you've misunderstood the meaning of encodeURL(). This doesn't
URL-encode a string (yes it does sound similar :) ) It adds the session id if
you're using URL rewriting to maintain sessions. See
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/servletapi/javax/servlet/http/HttpServletResponse.html#encodeURL(java.lang.String)


The correct way to write your code would be:
 <%
response.sendRedirect(response.encodeRedirectURL("bug.jsp?ready="+java.net.URLEncoder.encode("Saturday
04:30"))); %>

this is JDK 1.3, in JDK 1.4, URLEncoder.encode(String) is deprecated and you
need to specify the charset for encoding:
<%
response.sendRedirect(response.encodeRedirectURL("bug.jsp?ready="+java.net.URLEncoder.encode("Saturday
04:30","UTF8"))); %>

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message