tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antti Rauramo <antti.raur...@index.fi>
Subject Cookie values
Date Tue, 01 Oct 2002 07:53:18 GMT
Hi!

I had a problem with accented characters Cookie values, and also just a 
little longer Strings. Tomcat threw an IllegalArgumentException in 
maybeQuote like this:

java.lang.IllegalArgumentException: =?ISO-8859-1?Q?
(keinotekoinen_AND_=E4lykkyys)?=
 =?ISO-8859-1?Q?_AND_NOT_nodetype:ALL=5FCONTENT?=
        at org.apache.tomcat.util.http.ServerCookie.maybeQuote
(ServerCookie.java:315)
        at org.apache.tomcat.util.http.ServerCookie.appendCookieValue
(ServerCookie.java:248)
        at org.apache.coyote.tomcat4.CoyoteResponse.addCookie
(CoyoteResponse.java:853)
        at org.apache.coyote.tomcat4.CoyoteResponseFacade.addCookie
(CoyoteResponseFacade.java:278)
[...etc]

I searched the web and found a couple of other people asking the same 
question, but no answers. 

So, Sun's javax.servlet.http.Cookie and Tomcat's javadocs say that the 
Cookie's value can be anything, but also that "If you use a binary value, 
you may want to use BASE64 encoding." and that "With Version 0 
cookies, values should not contain white space, brackets, parentheses, 
equals signs, commas, double quotes, slashes, question marks, at signs, 
colons, and semicolons."

That's a contradiction, isn't it? BASE64 results in data that may have white 
space (newlines).

But the Netscape's cookie definition says "This string is a sequence of 
characters excluding semi-colon, comma and white space. If there is a need 
to place such data in the name or value, some encoding method such as 
URL style %XX encoding is recommended, though no encoding is defined 
or required."

And so with URLEncoding this thing finally works! But I'd say that 
BASE64 is a bug in Sun's and Tomcat's javadocs. And maybe also Tomcat 
should be able to handle such values without throwing an exception...

Tell me I'm wrong, or go fix the javadocs!

References:
http://java.sun.com/j2ee/sdk_
1.3/techdocs/api/javax/servlet/http/Cookie.html#setValue(java.lang.String)

http://jakarta.apache.org/tomcat/tomcat-4.0-
doc/servletapi/javax/servlet/http/Cookie.html#setValue(java.lang.String)

http://wp.netscape.com/newsref/std/cookie_spec.html

--
Antti Rauramo
Index Information Technologies
antti.rauramo@index.fi
+358-40-5190209




--
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