Workaround for space in cookie name

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1571 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-12-09 11:28:54 +00:00
parent 5791ce19c3
commit 405dad0eef
1 changed files with 11 additions and 0 deletions

View File

@ -29,12 +29,20 @@ public class DavMailCookieSpec extends RFC2109Spec {
@Override
public void validate(String host, int port, String path,
boolean secure, final Cookie cookie) throws MalformedCookieException {
// workaround for space in cookie name
String cookieName = cookie.getName();
if (cookieName != null && cookieName.indexOf(' ') >= 0) {
cookie.setName(cookieName.replaceAll(" ", ""));
} else {
cookieName = null;
}
// workaround for invalid cookie path
String cookiePath = cookie.getPath();
if (cookiePath != null && !path.startsWith(cookiePath)) {
cookie.setPath(path);
} else {
cookiePath = null;
}
String hostWithoutDomain = host.substring(0, host.length()
- cookie.getDomain().length());
int dotIndex = hostWithoutDomain.indexOf('.');
@ -47,5 +55,8 @@ public class DavMailCookieSpec extends RFC2109Spec {
if (cookieName != null) {
cookie.setName(cookieName);
}
if (cookiePath != null) {
cookie.setPath(cookiePath);
}
}
}