From d99f8b286615b17f27984e23b992a5504c972d54 Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 6 Oct 2009 21:06:37 +0000 Subject: [PATCH] Caldav: improve getICSValue, do not return values inside VALARM section git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@766 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index ca97a53d..2818c09b 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -2106,13 +2106,19 @@ public class ExchangeSession { } protected String getICSValue(String icsBody, String prefix, String defval) throws IOException { + // only return values in VEVENT section, not VALARM + Stack sectionStack = new Stack(); BufferedReader reader = null; try { reader = new ICSBufferedReader(new StringReader(icsBody)); String line; while ((line = reader.readLine()) != null) { - if (line.startsWith(prefix)) { + if (line.startsWith("BEGIN:")) { + sectionStack.push(line); + } else if (line.startsWith("END:") && !sectionStack.isEmpty()) { + sectionStack.pop(); + } else if (!sectionStack.isEmpty() && "BEGIN:VEVENT".equals(sectionStack.peek()) && line.startsWith(prefix)) { return line.substring(prefix.length()); } } @@ -2131,16 +2137,7 @@ public class ExchangeSession { } protected String getICSDescription(String icsBody) throws IOException { - String description = getICSValue(icsBody, "DESCRIPTION:", ""); - - if ("reminder".equalsIgnoreCase(description)) { - // Ignore this as a description text because - // it's likely part of the valarm segment - // (the default valarm description from outlook is "reminder") - return ""; - } - - return description; + return getICSValue(icsBody, "DESCRIPTION:", ""); } static class Participants {