Author: remy.maucherat(a)jboss.com
Date: 2009-10-31 14:31:47 -0400 (Sat, 31 Oct 2009)
New Revision: 1233
Modified:
trunk/java/org/apache/tomcat/util/http/Cookies.java
trunk/java/org/apache/tomcat/util/http/ServerCookie.java
trunk/res/jboss/org/apache/catalina/startup/catalina.properties
Log:
- Cookie update, and restore the version switch for comments.
Modified: trunk/java/org/apache/tomcat/util/http/Cookies.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/Cookies.java 2009-10-30 16:18:49 UTC (rev
1232)
+++ trunk/java/org/apache/tomcat/util/http/Cookies.java 2009-10-31 18:31:47 UTC (rev
1233)
@@ -53,6 +53,12 @@
public static final boolean STRICT_SERVLET_COMPLIANCE;
/**
+ * If true, cookie values are allowed to contain an equals character without
+ * being quoted.
+ */
+ public static final boolean ALLOW_EQUALS_IN_VALUE;
+
+ /**
* If set to true, the <code>/</code> character will be treated as a
* separator. Default is usually false. If STRICT_SERVLET_COMPLIANCE==true
* then default is true. Explicitly setting always takes priority.
@@ -70,6 +76,10 @@
"org.apache.catalina.STRICT_SERVLET_COMPLIANCE",
"false")).booleanValue();
+ ALLOW_EQUALS_IN_VALUE = Boolean.valueOf(System.getProperty(
+
"org.apache.tomcat.util.http.ServerCookie.ALLOW_EQUALS_IN_VALUE",
+ "false")).booleanValue();
+
String fwdSlashIsSeparator = System.getProperty(
"org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR");
if (fwdSlashIsSeparator == null) {
@@ -588,7 +598,11 @@
*/
public static final int getTokenEndPosition(byte bytes[], int off, int end){
int pos = off;
- while (pos < end && !isSeparator(bytes[pos])) {pos++; }
+ while (pos < end &&
+ (!isSeparator(bytes[pos]) ||
+ bytes[pos]=='=' && ALLOW_EQUALS_IN_VALUE)) {
+ pos++;
+ }
if (pos > end)
return end;
Modified: trunk/java/org/apache/tomcat/util/http/ServerCookie.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/ServerCookie.java 2009-10-30 16:18:49 UTC (rev
1232)
+++ trunk/java/org/apache/tomcat/util/http/ServerCookie.java 2009-10-31 18:31:47 UTC (rev
1233)
@@ -75,6 +75,14 @@
public static final boolean STRICT_SERVLET_COMPLIANCE;
/**
+ * If set to false, we don't auto switch invalid v0 cookies to v1 and add
+ * quotes to make them valid.
+ * Default is usually true. If STRICT_SERVLET_COMPLIANCE==true then default
+ * is false. Explicitly setting always takes priority.
+ */
+ public static final boolean ALLOW_VERSION_SWITCH;
+
+ /**
* If set to false, we don't use the IE6/7 Max-Age/Expires work around.
* Default is usually true. If STRICT_SERVLET_COMPLIANCE==true then default
* is false. Explicitly setting always takes priority.
@@ -97,6 +105,15 @@
"false")).booleanValue();
+ String allowVersionSwitch = System.getProperty(
+
"org.apache.tomcat.util.http.ServerCookie.ALLOW_VERSION_SWITCH");
+ if (allowVersionSwitch == null) {
+ ALLOW_VERSION_SWITCH = STRICT_SERVLET_COMPLIANCE;
+ } else {
+ ALLOW_VERSION_SWITCH =
+ Boolean.valueOf(allowVersionSwitch).booleanValue();
+ }
+
String alwaysAddExpires = System.getProperty(
"org.apache.tomcat.util.http.ServerCookie.ALWAYS_ADD_EXPIRES");
if (alwaysAddExpires == null) {
@@ -301,6 +318,11 @@
buf.append("=");
// Servlet implementation does not check anything else
+ // Switch version if allowed and a comment has been configured
+ if (version == 0 && comment != null && ALLOW_VERSION_SWITCH) {
+ version = 1;
+ }
+
version = maybeQuote2(version, buf, value,true);
// Add version 1 specific information
@@ -400,7 +422,7 @@
buf.append('"');
buf.append(escapeDoubleQuotes(value,1,value.length()-1));
buf.append('"');
- } else if (allowVersionSwitch && (!STRICT_SERVLET_COMPLIANCE) &&
version==0 && !isToken2(value, literals)) {
+ } else if (allowVersionSwitch && ALLOW_VERSION_SWITCH &&
version==0 && !isToken2(value, literals)) {
buf.append('"');
buf.append(escapeDoubleQuotes(value,0,value.length()));
buf.append('"');
Modified: trunk/res/jboss/org/apache/catalina/startup/catalina.properties
===================================================================
--- trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2009-10-30 16:18:49
UTC (rev 1232)
+++ trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2009-10-31 18:31:47
UTC (rev 1233)
@@ -11,7 +11,6 @@
org.apache.catalina.core.StandardHost.deployOnStartup=false
org.apache.catalina.core.StandardHost.deployXML=false
org.apache.catalina.core.StandardHost.startChildren=false
-org.apache.tomcat.util.http.ServerCookie.VERSION_SWITCH=true
# String cache configuration.
org.apache.tomcat.util.buf.StringCache.byte.enabled=true
Show replies by date