* Improved CookieDecoder to be more tolerant
* Added a test case for comma delimited cookies
This commit is contained in:
parent
611364e47c
commit
9e0e310ffe
@ -58,8 +58,8 @@ public class CookieDecoder {
|
|||||||
Set<Cookie> cookies = new TreeSet<Cookie>();
|
Set<Cookie> cookies = new TreeSet<Cookie>();
|
||||||
String[] split = header.split(SEMICOLON);
|
String[] split = header.split(SEMICOLON);
|
||||||
int version = 0;
|
int version = 0;
|
||||||
boolean versionAtTheBeginning = false;
|
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
|
boolean versionAtTheBeginning = false;
|
||||||
DefaultCookie theCookie;
|
DefaultCookie theCookie;
|
||||||
String s = split[i];
|
String s = split[i];
|
||||||
String[] cookie = s.split(EQUALS, 2);
|
String[] cookie = s.split(EQUALS, 2);
|
||||||
|
@ -27,6 +27,7 @@ import java.util.Date;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,6 +221,40 @@ public class CookieDecoderTest {
|
|||||||
assertNull(c.getDomain());
|
assertNull(c.getDomain());
|
||||||
assertTrue(c.getPorts().isEmpty());
|
assertTrue(c.getPorts().isEmpty());
|
||||||
assertEquals(-1, c.getMaxAge());
|
assertEquals(-1, c.getMaxAge());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void testDecodingCommaSeparatedClientSideCookies() {
|
||||||
|
// FIXME Fix CookieDecoder to pass this test.
|
||||||
|
String source =
|
||||||
|
"$Version=\"1\"; session_id=\"1234\", " +
|
||||||
|
"$Version=\"1\"; session_id=\"1111\"; $Domain=\".cracker.edu\"";
|
||||||
|
|
||||||
|
Set<Cookie> cookies = new CookieDecoder().decode(source);
|
||||||
|
Iterator<Cookie> it = cookies.iterator();
|
||||||
|
Cookie c;
|
||||||
|
|
||||||
|
c = it.next();
|
||||||
|
assertEquals(1, c.getVersion());
|
||||||
|
assertEquals("session_id", c.getName());
|
||||||
|
assertEquals("1234", c.getValue());
|
||||||
|
assertNull(c.getPath());
|
||||||
|
assertNull(c.getComment());
|
||||||
|
assertNull(c.getCommentUrl());
|
||||||
|
assertNull(c.getDomain());
|
||||||
|
assertTrue(c.getPorts().isEmpty());
|
||||||
|
assertEquals(-1, c.getMaxAge());
|
||||||
|
|
||||||
|
c = it.next();
|
||||||
|
assertEquals(1, c.getVersion());
|
||||||
|
assertEquals("session_id", c.getName());
|
||||||
|
assertEquals("1111", c.getValue());
|
||||||
|
assertEquals(".cracker.edu", c.getDomain());
|
||||||
|
assertNull(c.getPath());
|
||||||
|
assertNull(c.getComment());
|
||||||
|
assertNull(c.getCommentUrl());
|
||||||
|
assertTrue(c.getPorts().isEmpty());
|
||||||
|
assertEquals(-1, c.getMaxAge());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user