Author: markt
Date: Tue Sep 30 07:52:15 2014
New Revision: 1628368
URL: http://svn.apache.org/r1628368
Log:
Deprecate CookieSupport class.
Requires copying isV0Separator(char) to LegacyCookieProcessor
Modified:
tomcat/trunk/java/org/apache/tomcat/util/http/CookieSupport.java
tomcat/trunk/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/http/CookieSupport.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/CookieSupport.java?rev=1628368&r1=1628367&r2=1628368&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/CookieSupport.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/CookieSupport.java Tue Sep 30
07:52:15 2014
@@ -19,7 +19,10 @@ package org.apache.tomcat.util.http;
/**
* Static constants for this package.
+ *
+ * @deprecated Will be removed in Tomcat 9.
*/
+@Deprecated
public final class CookieSupport {
// ---------------------------------------------------------------
Constants
@@ -32,10 +35,7 @@ public final class CookieSupport {
/**
* If true, cookie values are allowed to contain an equals character
without
* being quoted.
- *
- * @deprecated Will be removed in Tomcat 9.
*/
- @Deprecated
public static final boolean ALLOW_EQUALS_IN_VALUE;
/**
@@ -43,37 +43,25 @@ public final class CookieSupport {
* spec but are disallowed by the HTTP spec will be allowed in v0 cookie
* names and values. These characters are: \"()/:<=>?@[\\]{} Note that the
* inclusion of / depends on the value of {@link #FWD_SLASH_IS_SEPARATOR}.
- *
- * @deprecated Will be removed in Tomcat 9.
*/
- @Deprecated
public static final boolean ALLOW_HTTP_SEPARATORS_IN_V0;
/**
* 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.
- *
- * @deprecated Will be removed in Tomcat 9.
*/
- @Deprecated
public static final boolean FWD_SLASH_IS_SEPARATOR;
/**
* If true, name only cookies will be permitted.
- *
- * @deprecated Will be removed in Tomcat 9.
*/
- @Deprecated
public static final boolean ALLOW_NAME_ONLY;
/**
* If set to true, the cookie header will be preserved. In most cases
* except debugging, this is not useful.
- *
- * @deprecated Will be removed in Tomcat 9.
*/
- @Deprecated
public static final boolean PRESERVE_COOKIE_HEADER;
/**
@@ -177,10 +165,7 @@ public final class CookieSupport {
* spec, RFC2109.
* @throws IllegalArgumentException if a control character was supplied as
* input
- *
- * @deprecated Will be removed in Tomcat 9.
*/
- @Deprecated
public static final boolean isHttpSeparator(final char c) {
if (c < 0x20 || c >= 0x7f) {
if (c != 0x09) {
Modified:
tomcat/trunk/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java?rev=1628368&r1=1628367&r2=1628368&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/LegacyCookieProcessor.java
Tue Sep 30 07:52:15 2014
@@ -44,12 +44,22 @@ public final class LegacyCookieProcessor
private static final StringManager sm =
StringManager.getManager("org.apache.tomcat.util.http");
+ private static final char[] V0_SEPARATORS = {',', ';', ' ', '\t'};
+ private static final boolean[] V0_SEPARATOR_FLAGS = new boolean[128];
+
// Excludes '/' since configuration controls whether or not to treat '/' as
// a separator
private static final char[] HTTP_SEPARATORS = new char[] {
'\t', ' ', '\"', '(', ')', ',', ':', ';', '<', '=', '>', '?', '@',
'[', '\\', ']', '{', '}' };
+ static {
+ for (char c : V0_SEPARATORS) {
+ V0_SEPARATOR_FLAGS[c] = true;
+ }
+ }
+
+
@SuppressWarnings("deprecation") // Default to false when deprecated code
is removed
private boolean allowEqualsInValue = CookieSupport.ALLOW_EQUALS_IN_VALUE;
@@ -206,7 +216,7 @@ public final class LegacyCookieProcessor
while (pos < end &&
(isHttpSeparator((char) bytes[pos]) &&
!getAllowHttpSepsInV0() ||
- CookieSupport.isV0Separator((char) bytes[pos]) ||
+ isV0Separator((char) bytes[pos]) ||
isWhiteSpace(bytes[pos])))
{pos++; }
@@ -271,7 +281,7 @@ public final class LegacyCookieProcessor
break;
default:
if (version == 0 &&
- !CookieSupport.isV0Separator((char)bytes[pos])
&&
+ isV0Separator((char)bytes[pos]) &&
getAllowHttpSepsInV0() ||
!isHttpSeparator((char)bytes[pos]) ||
bytes[pos] == '=') {
@@ -442,7 +452,7 @@ public final class LegacyCookieProcessor
while (pos < end &&
(!isHttpSeparator((char)bytes[pos]) ||
version == 0 && getAllowHttpSepsInV0() && bytes[pos] != '=' &&
- !CookieSupport.isV0Separator((char)bytes[pos]) ||
+ !isV0Separator((char)bytes[pos]) ||
!isName && bytes[pos] == '=' && getAllowEqualsInValue())) {
pos++;
}
@@ -465,6 +475,23 @@ public final class LegacyCookieProcessor
return httpSeparatorFlags[c];
}
+
+ /**
+ * Returns true if the byte is a separator as defined by V0 of the cookie
+ * spec.
+ */
+ private static boolean isV0Separator(final char c) {
+ if (c < 0x20 || c >= 0x7f) {
+ if (c != 0x09) {
+ throw new IllegalArgumentException(
+ "Control character in cookie value or attribute.");
+ }
+ }
+
+ return V0_SEPARATOR_FLAGS[c];
+ }
+
+
/**
* Given a starting position after an initial quote character, this gets
* the position of the end quote. This escapes anything after a '\' char
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]