diff --git a/src/java/davmail/caldav/CaldavConnection.java b/src/java/davmail/caldav/CaldavConnection.java index 8f66276b..442d6799 100644 --- a/src/java/davmail/caldav/CaldavConnection.java +++ b/src/java/davmail/caldav/CaldavConnection.java @@ -274,7 +274,7 @@ public class CaldavConnection extends AbstractConnection { ExchangeSession.Folder folder = session.getFolder(folderPath); if (folder.isContact()) { sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(folder.etag), "text/vcard", (byte[]) null, true); - } else { + } else if (folder.isCalendar()) { List events = session.getAllEvents(folderPath); ChunkedResponse response = new ChunkedResponse(HttpStatus.SC_OK, "text/calendar;charset=UTF-8"); response.append("BEGIN:VCALENDAR\r\n"); @@ -297,6 +297,8 @@ public class CaldavConnection extends AbstractConnection { } response.append("END:VCALENDAR"); response.close(); + } else { + sendHttpResponse(HttpStatus.SC_OK, buildEtagHeader(folder.etag), "text/html", (byte[]) null, true); } } else { ExchangeSession.Item item = session.getItem(request.getFolderPath(), lastPath); @@ -1255,7 +1257,7 @@ public class CaldavConnection extends AbstractConnection { * @return true if this is a folder (not event) request */ public boolean isFolder() { - return isPropFind() || isReport() || isPropPatch() || isOptions() || isPost(); + return path.endsWith("/") || isPropFind() || isReport() || isPropPatch() || isOptions() || isPost(); } public boolean isRoot() { diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 07f27e72..d8bd22e7 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -1050,9 +1050,11 @@ public class EwsExchangeSession extends ExchangeSession { private FolderId getFolderIdIfExists(String folderPath) throws IOException { String[] folderNames; FolderId currentFolderId; - String currentMailboxPath = "/users/" + email + '/'; - if (folderPath.startsWith(currentMailboxPath)) { - return getFolderIdIfExists(folderPath.substring(currentMailboxPath.length())); + String currentMailboxPath = "/users/" + email; + if (currentMailboxPath.equals(folderPath)) { + return DistinguishedFolderId.MSGFOLDERROOT; + } else if (folderPath.startsWith(currentMailboxPath + '/')) { + return getFolderIdIfExists(folderPath.substring(currentMailboxPath.length()+1)); } if (folderPath.startsWith(PUBLIC_ROOT)) { currentFolderId = DistinguishedFolderId.PUBLICFOLDERSROOT;