Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 63737 invoked from network); 1 Oct 2002 07:54:45 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 1 Oct 2002 07:54:45 -0000 Received: (qmail 15358 invoked by uid 97); 1 Oct 2002 07:55:31 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 15316 invoked by uid 97); 1 Oct 2002 07:55:30 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 15273 invoked by uid 98); 1 Oct 2002 07:55:28 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) From: Antti Rauramo To: tomcat-dev@jakarta.apache.org Date: Tue, 01 Oct 2002 10:53:18 +0300 X-Priority: 3 (Normal) Reply-To: antti.rauramo@index.fi Organization: Index IT Oy Message-Id: Subject: Cookie values MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Mailer: Opera 6.05 build 1140 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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: For additional commands, e-mail: