You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2008/03/19 04:46:18 UTC

svn commit: r638695 - /tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java

Author: fhanik
Date: Tue Mar 18 20:46:17 2008
New Revision: 638695

URL: http://svn.apache.org/viewvc?rev=638695&view=rev
Log:
Only allow version switching on the "value" of the cookie, for the rest, just quote like we did in the past. this becomes the most backwards compatible with old behavior

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java?rev=638695&r1=638694&r2=638695&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/ServerCookie.java Tue Mar 18 20:46:17 2008
@@ -255,7 +255,7 @@
         buf.append("=");
         // Servlet implementation does not check anything else
         
-        version = maybeQuote2(version, buf, value);
+        version = maybeQuote2(version, buf, value,true);
 
         // Add version 1 specific information
         if (version == 1) {
@@ -299,10 +299,7 @@
         // Path=path
         if (path!=null) {
             buf.append ("; Path=");
-            if (version>0)
-                maybeQuote2(version, buf, path); //don't quote the path for v0 cookies
-            else
-                buf.append(path);
+            maybeQuote2(version, buf, path);
         }
 
         // Secure
@@ -340,6 +337,10 @@
      * @param value
      */
     public static int maybeQuote2 (int version, StringBuffer buf, String value) {
+        return maybeQuote2(version,buf,value,false);
+    }
+
+    public static int maybeQuote2 (int version, StringBuffer buf, String value, boolean allowVersionSwitch) {
         if (value==null || value.length()==0) {
             buf.append("\"\"");
         }else if (containsCTL(value,version)) 
@@ -348,7 +349,7 @@
             buf.append('"');
             buf.append(escapeDoubleQuotes(value,1,value.length()-1));
             buf.append('"');
-        } else if ((!STRICT_SERVLET_COMPLIANCE) && version==0 && !isToken2(value)) {
+        } else if (allowVersionSwitch && (!STRICT_SERVLET_COMPLIANCE) && version==0 && !isToken2(value)) {
             buf.append('"');
             buf.append(escapeDoubleQuotes(value,0,value.length()));
             buf.append('"');



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