You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2003/06/12 21:12:18 UTC
cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestCookie.java
olegk 2003/06/12 12:12:17
Modified: httpclient/src/java/org/apache/commons/httpclient/cookie
CookieSpecBase.java
httpclient/src/test/org/apache/commons/httpclient
TestCookie.java
Log:
RFC2109 cookie spec implementation does not properly handle default cookie path with a single leading back-slash ('/whatever.php'). Default cookie path with multiple back-slashes is processed correctly ('/path/whatever.php')
Reported by Dan Ã…berg <da...@staff.spray.se>
Contributed by Oleg Kalnichevski
Revision Changes Path
1.16 +8 -4 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java
Index: CookieSpecBase.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- CookieSpecBase.java 26 May 2003 17:58:03 -0000 1.15
+++ CookieSpecBase.java 12 Jun 2003 19:12:16 -0000 1.16
@@ -176,7 +176,11 @@
String defaultPath = path;
int lastSlashIndex = defaultPath.lastIndexOf(PATH_DELIM);
- if (lastSlashIndex > 0) {
+ if (lastSlashIndex >= 0) {
+ if (lastSlashIndex == 0) {
+ //Do not remove the very first slash
+ lastSlashIndex = 1;
+ }
defaultPath = defaultPath.substring(0, lastSlashIndex);
}
1.22 +21 -4 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java
Index: TestCookie.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- TestCookie.java 7 Mar 2003 18:23:46 -0000 1.21
+++ TestCookie.java 12 Jun 2003 19:12:16 -0000 1.22
@@ -298,6 +298,23 @@
}
+ public void testParseSimple2() throws Exception {
+ Header setCookie = new Header("Set-Cookie","cookie-name=cookie-value");
+ Cookie[] parsed = cookieParse("127.0.0.1","/path",setCookie);
+ assertEquals("Found 1 cookie.",1,parsed.length);
+ assertEquals("Name","cookie-name",parsed[0].getName());
+ assertEquals("Value","cookie-value",parsed[0].getValue());
+ assertTrue("Comment",null == parsed[0].getComment());
+ assertTrue("ExpiryDate",null == parsed[0].getExpiryDate());
+ //assertTrue("isToBeDiscarded",parsed[0].isToBeDiscarded());
+ assertTrue("isPersistent",!parsed[0].isPersistent());
+ assertEquals("Domain","127.0.0.1",parsed[0].getDomain());
+ assertEquals("Path","/",parsed[0].getPath());
+ assertTrue("Secure",!parsed[0].getSecure());
+ assertEquals("Version",0,parsed[0].getVersion());
+ }
+
+
public void testParseNoValue() throws Exception {
Header setCookie = new Header("Set-Cookie","cookie-name=");
Cookie[] parsed = cookieParse("127.0.0.1","/",setCookie);
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org