Author: mmillson
Date: 2010-02-02 10:20:12 -0500 (Tue, 02 Feb 2010)
New Revision: 1378
Modified:
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-3629/src/share/classes/org/apache/tomcat/util/http/Cookies.java
Log:
Allow equals sign in version0 cookie values for [JBPAPP-3629].
Modified:
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-3629/src/share/classes/org/apache/tomcat/util/http/Cookies.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-3629/src/share/classes/org/apache/tomcat/util/http/Cookies.java 2010-02-02
14:42:08 UTC (rev 1377)
+++
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-3629/src/share/classes/org/apache/tomcat/util/http/Cookies.java 2010-02-02
15:20:12 UTC (rev 1378)
@@ -46,6 +46,12 @@
MimeHeaders headers;
+ /**
+ * If true, cookie values are allowed to contain an equals character without
+ * being quoted.
+ */
+ public static final boolean ALLOW_EQUALS_IN_VALUE;
+
/*
List of Separator Characters (see isSeparator())
Excluding the '/' char violates the RFC, but
@@ -65,6 +71,10 @@
for (int i = 0; i < SEPARATORS.length; i++) {
separators[SEPARATORS[i]] = true;
}
+
+ ALLOW_EQUALS_IN_VALUE = Boolean.valueOf(System.getProperty(
+
"org.apache.tomcat.util.http.ServerCookie.ALLOW_EQUALS_IN_VALUE",
+ "false")).booleanValue();
}
/**
@@ -367,7 +377,7 @@
// Get the cookie name. This must be a token
valueEnd = valueStart = nameStart = pos;
- pos = nameEnd = getTokenEndPosition(bytes,pos,end);
+ pos = nameEnd = getTokenEndPosition(bytes,pos,end,true);
// Skip whitespace
while (pos < end && isWhiteSpace(bytes[pos])) {pos++; };
@@ -414,12 +424,14 @@
// The position is OK (On a delimiter)
break;
default:;
- if (!isSeparator(bytes[pos])) {
+ if (!isSeparator(bytes[pos]) ||
+ bytes[pos] == '=' && ALLOW_EQUALS_IN_VALUE)
{
// Token
valueStart=pos;
// getToken returns the position at the delimeter
// or other non-token character
- valueEnd=getTokenEndPosition(bytes, valueStart, end);
+ valueEnd = getTokenEndPosition(bytes, valueStart, end,
+ false);
// We need pos to advance
pos = valueEnd;
} else {
@@ -551,13 +563,26 @@
}
/**
+ * @deprecated - Use private method
+ * {@link #getTokenEndPosition(byte[], int, int, boolean)} instead
+ */
+ public static final int getTokenEndPosition(byte bytes[], int off, int end){
+ return getTokenEndPosition(bytes, off, end, true);
+ }
+
+ /**
* Given the starting position of a token, this gets the end of the
* token, with no separator characters in between.
* JVK
*/
- public static final int getTokenEndPosition(byte bytes[], int off, int end){
+ private static final int getTokenEndPosition(byte bytes[], int off, int end,
+ boolean isName) {
int pos = off;
- while (pos < end && !isSeparator(bytes[pos])) {pos++; };
+ while (pos < end &&
+ (!isSeparator(bytes[pos]) ||
+ bytes[pos]=='=' && ALLOW_EQUALS_IN_VALUE &&
!isName)) {
+ pos++;
+ }
if (pos > end)
return end;
Show replies by date