Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2013-08-15 00:01:19 +0000
committerGreg Wilkins2013-08-15 00:01:19 +0000
commit44b07f44bb043df6ee57f2bb54d3fde2eda7d0c5 (patch)
tree2dfc3eb07c3f3d41567a40bf6789a4fd69df560d /jetty-http
parent9f13a0e146422bee1a7896ecaca4894472499189 (diff)
parent89f927ad0f60aa113ad1c2cfbacc64827ec679b0 (diff)
downloadorg.eclipse.jetty.project-44b07f44bb043df6ee57f2bb54d3fde2eda7d0c5.tar.gz
org.eclipse.jetty.project-44b07f44bb043df6ee57f2bb54d3fde2eda7d0c5.tar.xz
org.eclipse.jetty.project-44b07f44bb043df6ee57f2bb54d3fde2eda7d0c5.zip
Merge remote-tracking branch 'origin/master' into jetty-9.1
Diffstat (limited to 'jetty-http')
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java33
-rw-r--r--jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java4
2 files changed, 5 insertions, 32 deletions
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java
index 0df296425e..c6b6762aa0 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java
@@ -69,8 +69,7 @@ public class HttpFields implements Iterable<HttpField>
public static final TimeZone __GMT = TimeZone.getTimeZone("GMT");
public static final DateCache __dateCache = new DateCache("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
- public static final String __COOKIE_DELIM_PATH="\"\\\t%+ :;,@?=()<>{}[]";
- public static final String __COOKIE_DELIM=__COOKIE_DELIM_PATH+"/";
+ public static final String __COOKIE_DELIM="\",;\\ \t";
static
{
@@ -822,7 +821,7 @@ public class HttpFields implements Iterable<HttpField>
// Format value and params
StringBuilder buf = new StringBuilder(128);
- // Name is checked by servlet spec, but can also be passed directly so check again
+ // Name is checked for legality by servlet spec, but can also be passed directly so check again for quoting
boolean quote_name=isQuoteNeededForCookie(name);
quoteOnlyOrAppend(buf,name,quote_name);
@@ -839,7 +838,7 @@ public class HttpFields implements Iterable<HttpField>
boolean has_domain = domain!=null && domain.length()>0;
boolean quote_domain = has_domain && isQuoteNeededForCookie(domain);
boolean has_path = path!=null && path.length()>0;
- boolean quote_path = has_path && isQuoteNeededForCookiePath(path);
+ boolean quote_path = has_path && isQuoteNeededForCookie(path);
// Upgrade the version if we have a comment or we need to quote value/path/domain or if they were already quoted
if (version==0 && ( comment!=null || quote_name || quote_value || quote_domain || quote_path || isQuoted(name) || isQuoted(value) || isQuoted(path) || isQuoted(domain)))
@@ -1177,32 +1176,6 @@ public class HttpFields implements Iterable<HttpField>
return false;
}
- /* ------------------------------------------------------------ */
- /** Does a cookie path need to be quoted?
- * @param s value string
- * @return true if quoted;
- * @throws IllegalArgumentException If there a control characters in the string
- */
- public static boolean isQuoteNeededForCookiePath(String s)
- {
- if (s==null || s.length()==0)
- return true;
-
- if (QuotedStringTokenizer.isQuoted(s))
- return false;
-
- for (int i=0;i<s.length();i++)
- {
- char c = s.charAt(i);
- if (__COOKIE_DELIM_PATH.indexOf(c)>=0)
- return true;
-
- if (c<0x20 || c>=0x7f)
- throw new IllegalArgumentException("Illegal character in cookie value");
- }
-
- return false;
- }
private static void quoteOnlyOrAppend(StringBuilder buf, String s, boolean quote)
{
diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java
index d1674aa743..a55b34f389 100644
--- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java
+++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java
@@ -374,9 +374,9 @@ public class HttpFieldsTest
assertEquals("foo=bob;Domain=domain",e.nextElement());
fields=new HttpFields();
- fields.addSetCookie("name","value==",null,null,-1,null,false,false,0);
+ fields.addSetCookie("name","value%=",null,null,-1,null,false,false,0);
setCookie=fields.getStringField("Set-Cookie");
- assertEquals("name=\"value==\";Version=1",setCookie);
+ assertEquals("name=value%=",setCookie);
}

Back to the top