diff --git a/src/java/davmail/http/DavMailCookieSpec.java b/src/java/davmail/http/DavMailCookieSpec.java index bae768b0..f20537b7 100644 --- a/src/java/davmail/http/DavMailCookieSpec.java +++ b/src/java/davmail/http/DavMailCookieSpec.java @@ -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); + } } }