hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1778459 - in /httpcomponents/httpclient/branches/4.5.x/httpclient/src: main/java/org/apache/http/impl/cookie/ test/java/org/apache/http/impl/cookie/
Date Thu, 12 Jan 2017 19:20:44 GMT
Author: olegk
Date: Thu Jan 12 19:20:44 2017
New Revision: 1778459

URL: http://svn.apache.org/viewvc?rev=1778459&view=rev
Log:
HTTPCLIENT-1788: RFC 6265 policy must not reject cookies with paths that are no prefix of
the uri path

Modified:
    httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
    httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
    httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
    httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java

Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java?rev=1778459&r1=1778458&r2=1778459&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
(original)
+++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
Thu Jan 12 19:20:44 2017
@@ -32,7 +32,6 @@ import org.apache.http.cookie.ClientCook
 import org.apache.http.cookie.CommonCookieAttributeHandler;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
 import org.apache.http.util.Args;
@@ -59,11 +58,6 @@ public class BasicPathHandler implements
     @Override
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (!match(cookie, origin)) {
-            throw new CookieRestrictionViolationException(
-                "Illegal 'path' attribute \"" + cookie.getPath()
-                + "\". Path of origin: \"" + origin.getPath() + "\"");
-        }
     }
 
     static boolean pathMatch(final String uriPath, final String cookiePath) {

Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java?rev=1778459&r1=1778458&r2=1778459&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
(original)
+++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
Thu Jan 12 19:20:44 2017
@@ -72,7 +72,19 @@ public class RFC2109Spec extends CookieS
     /** Default constructor */
     public RFC2109Spec(final String[] datepatterns, final boolean oneHeader) {
         super(new RFC2109VersionHandler(),
-                new BasicPathHandler(),
+                new BasicPathHandler() {
+
+                    @Override
+                    public void validate(
+                            final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException
{
+                        if (!match(cookie, origin)) {
+                            throw new CookieRestrictionViolationException(
+                                    "Illegal 'path' attribute \"" + cookie.getPath()
+                                            + "\". Path of origin: \"" + origin.getPath()
+ "\"");
+                        }
+                    }
+
+                },
                 new RFC2109DomainHandler(),
                 new BasicMaxAgeHandler(),
                 new BasicSecureHandler(),

Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java?rev=1778459&r1=1778458&r2=1778459&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
(original)
+++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
Thu Jan 12 19:20:44 2017
@@ -43,6 +43,7 @@ import org.apache.http.cookie.CommonCook
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
+import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SM;
 import org.apache.http.message.BufferedHeader;
@@ -72,7 +73,19 @@ public class RFC2965Spec extends RFC2109
     public RFC2965Spec(final String[] datepatterns, final boolean oneHeader) {
         super(oneHeader,
                 new RFC2965VersionAttributeHandler(),
-                new BasicPathHandler(),
+                new BasicPathHandler() {
+
+                    @Override
+                    public void validate(
+                            final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException
{
+                        if (!match(cookie, origin)) {
+                            throw new CookieRestrictionViolationException(
+                                    "Illegal 'path' attribute \"" + cookie.getPath()
+                                            + "\". Path of origin: \"" + origin.getPath()
+ "\"");
+                        }
+                    }
+
+                },
                 new RFC2965DomainAttributeHandler(),
                 new RFC2965PortAttributeHandler(),
                 new BasicMaxAgeHandler(),

Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java?rev=1778459&r1=1778458&r2=1778459&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
(original)
+++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
Thu Jan 12 19:20:44 2017
@@ -298,22 +298,6 @@ public class TestBasicCookieAttribHandle
     }
 
     @Test
-    public void testBasicPathValidate() throws Exception {
-        final BasicClientCookie cookie = new BasicClientCookie("name", "value");
-        final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
-        final CookieAttributeHandler h = new BasicPathHandler();
-        cookie.setPath("/stuff");
-        h.validate(cookie, origin);
-        cookie.setPath("/stuffed");
-        try {
-            h.validate(cookie, origin);
-            Assert.fail("MalformedCookieException must have been thrown");
-        } catch (final MalformedCookieException ex) {
-            // expected
-        }
-    }
-
-    @Test
     public void testBasicPathInvalidInput() throws Exception {
         final CookieAttributeHandler h = new BasicPathHandler();
         try {



Mime
View raw message