HTTPCLIENT-1788: RFC 6265 policy must not reject cookies with paths that are no prefix of the uri path

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1778460 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2017-01-12 19:21:03 +00:00
parent 09bee18bd6
commit 4d180773db
2 changed files with 0 additions and 22 deletions

View File

@ -29,7 +29,6 @@ package org.apache.hc.client5.http.impl.cookie;
import org.apache.hc.client5.http.cookie.CommonCookieAttributeHandler;
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.cookie.CookieOrigin;
import org.apache.hc.client5.http.cookie.CookieRestrictionViolationException;
import org.apache.hc.client5.http.cookie.MalformedCookieException;
import org.apache.hc.client5.http.cookie.SetCookie;
import org.apache.hc.core5.annotation.Contract;
@ -58,11 +57,6 @@ public class BasicPathHandler implements CommonCookieAttributeHandler {
@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) {

View File

@ -297,22 +297,6 @@ public class TestBasicCookieAttribHandlers {
Assert.assertTrue(h.match(cookie, origin));
}
@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();