mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 11:12:22 -05:00
Workaround for malformed cookies with space in name
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1548 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
1a2d67afe0
commit
dd648bbf54
@ -28,14 +28,24 @@ import org.apache.commons.httpclient.cookie.RFC2109Spec;
|
|||||||
public class DavMailCookieSpec extends RFC2109Spec {
|
public class DavMailCookieSpec extends RFC2109Spec {
|
||||||
@Override
|
@Override
|
||||||
public void validate(String host, int port, String path,
|
public void validate(String host, int port, String path,
|
||||||
boolean secure, final Cookie cookie) throws MalformedCookieException {
|
boolean secure, final Cookie cookie) throws MalformedCookieException {
|
||||||
|
String cookieName = cookie.getName();
|
||||||
|
if (cookieName != null && cookieName.indexOf(' ') >= 0) {
|
||||||
|
cookie.setName(cookieName.replaceAll(" ", ""));
|
||||||
|
} else {
|
||||||
|
cookieName = null;
|
||||||
|
}
|
||||||
String hostWithoutDomain = host.substring(0, host.length()
|
String hostWithoutDomain = host.substring(0, host.length()
|
||||||
- cookie.getDomain().length());
|
- cookie.getDomain().length());
|
||||||
if (hostWithoutDomain.indexOf('.') != -1) {
|
int dotIndex = hostWithoutDomain.indexOf('.');
|
||||||
|
if (dotIndex != -1) {
|
||||||
// discard additional host name part
|
// discard additional host name part
|
||||||
super.validate(host.substring(hostWithoutDomain.indexOf('.')+1), port, path, secure, cookie);
|
super.validate(host.substring(dotIndex + 1), port, path, secure, cookie);
|
||||||
} else {
|
} else {
|
||||||
super.validate(host, port, path, secure, cookie);
|
super.validate(host, port, path, secure, cookie);
|
||||||
}
|
}
|
||||||
|
if (cookieName != null) {
|
||||||
|
cookie.setName(cookieName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user