Author: jim Date: Wed Mar 5 08:19:38 2008 New Revision: 633908 URL: http://svn.apache.org/viewvc?rev=633908&view=rev Log: Merge r627743, r630533 from trunk:
Add STRICT compliance flag to impact cookie value handling to provide backwards compatibility Add STRICT complanice flag to impact ServletContext.getResource(AsStream) to be backwards compatible Use the same name on the static variable for servlet compliance Submitted by: fhanik Reviewed by: jim Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=633908&r1=633907&r2=633908&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Wed Mar 5 08:19:38 2008 @@ -47,12 +47,6 @@ +1: fhanik, markt, remm, jfclere -1: -* Allow old style cookie values to work(auto switch to v1) (regression) - http://svn.apache.org/viewvc?view=rev&revision=627743 (ServerCookie.java) - http://svn.apache.org/viewvc?view=rev&revision=630533 (use the same variable name for all servlet compliance flags) - +1: fhanik, markt, jim - -1: - * Fix ArrayIndexOutOfBoundsException when empty URL is requested http://svn.apache.org/viewvc?rev=627883&view=rev +1: markt, jim Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java?rev=633908&r1=633907&r2=633908&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/ServerCookie.java Wed Mar 5 08:19:38 2008 @@ -51,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 @@ -248,7 +255,7 @@ buf.append("="); // Servlet implementation does not check anything else - maybeQuote2(version, buf, value); + version = maybeQuote2(version, buf, value); // Add version 1 specific information if (version == 1) { @@ -329,7 +336,7 @@ * @param buf * @param value */ - public static void maybeQuote2 (int version, StringBuffer buf, String value) { + public static int maybeQuote2 (int version, StringBuffer buf, String value) { if (value==null || value.length()==0) { buf.append("\"\""); }else if (containsCTL(value,version)) @@ -338,6 +345,11 @@ buf.append('"'); buf.append(escapeDoubleQuotes(value,1,value.length()-1)); buf.append('"'); + } else if ((!STRICT_SERVLET_COMPLIANCE) && version==0 && !isToken2(value)) { + buf.append('"'); + buf.append(escapeDoubleQuotes(value,0,value.length())); + buf.append('"'); + version = 1; } else if (version==0 && !isToken(value)) { buf.append('"'); buf.append(escapeDoubleQuotes(value,0,value.length())); @@ -349,6 +361,7 @@ }else { buf.append(value); } + return version; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]