Author: remy.maucherat(a)jboss.com
Date: 2008-03-21 20:02:21 -0400 (Fri, 21 Mar 2008)
New Revision: 535
Modified:
trunk/java/org/apache/tomcat/util/http/ServerCookie.java
trunk/webapps/docs/changelog.xml
Log:
- Apply latest cookie patch.
Modified: trunk/java/org/apache/tomcat/util/http/ServerCookie.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/ServerCookie.java 2008-03-21 15:40:49 UTC (rev
534)
+++ trunk/java/org/apache/tomcat/util/http/ServerCookie.java 2008-03-22 00:02:21 UTC (rev
535)
@@ -38,9 +38,6 @@
public class ServerCookie implements Serializable {
- protected static final boolean USE_V1_COOKIES =
-
!Boolean.valueOf(System.getProperty("org.apache.catalina.STRICT_SERVLET_COMPLIANCE",
"false")).booleanValue();
-
// Version 0 (Netscape) attributes
private MessageBytes name=MessageBytes.newInstance();
private MessageBytes value=MessageBytes.newInstance();
@@ -54,6 +51,13 @@
private int maxAge = -1;
private int version = 0;
+ /**
+ * If set to true, we parse cookies according to the servlet spec,
+ */
+ public static final boolean STRICT_SERVLET_COMPLIANCE =
+
Boolean.valueOf(System.getProperty("org.apache.catalina.STRICT_SERVLET_COMPLIANCE",
"false")).booleanValue();
+
+
// Note: Servlet Spec =< 2.5 only refers to Netscape and RFC2109,
// not RFC2965
@@ -251,20 +255,8 @@
buf.append("=");
// Servlet implementation does not check anything else
- version = maybeQuote2(version, buf, value);
+ version = maybeQuote2(version, buf, value,true);
- // Add domain information, if present
- if (domain!=null) {
- buf.append("; Domain=");
- version = maybeQuote2(version, buf, domain);
- }
-
- // Path=path
- if (path!=null) {
- buf.append ("; Path=");
- version = maybeQuote2(version, buf, path);
- }
-
// Add version 1 specific information
if (version == 1) {
// Version=1 ... required
@@ -277,6 +269,12 @@
}
}
+ // Add domain information, if present
+ if (domain!=null) {
+ buf.append("; Domain=");
+ maybeQuote2(version, buf, domain);
+ }
+
// Max-Age=secs ... or use old "Expires" format
// TODO RFC2965 Discard
if (maxAge >= 0) {
@@ -298,6 +296,12 @@
}
}
+ // Path=path
+ if (path!=null) {
+ buf.append ("; Path=");
+ maybeQuote2(version, buf, path);
+ }
+
// Secure
if (isSecure) {
buf.append ("; Secure");
@@ -333,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))
@@ -341,7 +349,7 @@
buf.append('"');
buf.append(escapeDoubleQuotes(value,1,value.length()-1));
buf.append('"');
- } else if (USE_V1_COOKIES && 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('"');
@@ -354,7 +362,7 @@
buf.append('"');
buf.append(escapeDoubleQuotes(value,0,value.length()));
buf.append('"');
- } else {
+ }else {
buf.append(value);
}
return version;
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-03-21 15:40:49 UTC (rev 534)
+++ trunk/webapps/docs/changelog.xml 2008-03-22 00:02:21 UTC (rev 535)
@@ -45,6 +45,9 @@
<fix>
Improve accuracy of typical timeout values. (remm)
</fix>
+ <fix>
+ Comet state recycling. (remm)
+ </fix>
</changelog>
</subsection>
</section>