hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1714368 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
Date Sat, 14 Nov 2015 20:48:26 GMT
Author: olegk
Date: Sat Nov 14 20:48:26 2015
New Revision: 1714368

URL: http://svn.apache.org/viewvc?rev=1714368&view=rev
Log:
HTTPCLIENT-1695: RFC 6265 compliant cookie spec to ignore cookies with empty name / missing
value

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java?rev=1714368&r1=1714367&r2=1714368&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java
Sat Nov 14 20:48:26 2015
@@ -128,10 +128,10 @@ public class RFC6265CookieSpec implement
         }
         final String name = tokenParser.parseToken(buffer, cursor, TOKEN_DELIMS);
         if (name.length() == 0) {
-            throw new MalformedCookieException("Cookie name is invalid: '" + header.toString()
+ "'");
+            return Collections.emptyList();
         }
         if (cursor.atEnd()) {
-            throw new MalformedCookieException("Cookie value is invalid: '" + header.toString()
+ "'");
+            return Collections.emptyList();
         }
         final int valueDelim = buffer.charAt(cursor.getPos());
         cursor.updatePos(cursor.getPos() + 1);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java?rev=1714368&r1=1714367&r2=1714368&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
Sat Nov 14 20:48:26 2015
@@ -93,22 +93,24 @@ public class TestRFC6265CookieSpec {
         cookiespec.parse(header, origin);
     }
 
-    @Test(expected = MalformedCookieException.class)
+    @Test
     public void testParseCookieMissingName() throws Exception {
         final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec();
 
         final Header header = new BasicHeader("Set-Cookie", "=blah ; this = stuff;");
         final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true);
-        cookiespec.parse(header, origin);
+        final List<Cookie> cookies = cookiespec.parse(header, origin);
+        Assert.assertEquals(0, cookies.size());
     }
 
-    @Test(expected = MalformedCookieException.class)
+    @Test
     public void testParseCookieMissingValue1() throws Exception {
         final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec();
 
         final Header header = new BasicHeader("Set-Cookie", "blah");
         final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true);
-        cookiespec.parse(header, origin);
+        final List<Cookie> cookies = cookiespec.parse(header, origin);
+        Assert.assertEquals(0, cookies.size());
     }
 
     @Test(expected = MalformedCookieException.class)



Mime
View raw message