1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-15 04:02:21 -05:00

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
This commit is contained in:
mguessan 2009-10-06 21:06:37 +00:00
parent cc9b6e56c3
commit d99f8b2866

View File

@ -2106,13 +2106,19 @@ public class ExchangeSession {
} }
protected String getICSValue(String icsBody, String prefix, String defval) throws IOException { protected String getICSValue(String icsBody, String prefix, String defval) throws IOException {
// only return values in VEVENT section, not VALARM
Stack<String> sectionStack = new Stack<String>();
BufferedReader reader = null; BufferedReader reader = null;
try { try {
reader = new ICSBufferedReader(new StringReader(icsBody)); reader = new ICSBufferedReader(new StringReader(icsBody));
String line; String line;
while ((line = reader.readLine()) != null) { 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()); return line.substring(prefix.length());
} }
} }
@ -2131,16 +2137,7 @@ public class ExchangeSession {
} }
protected String getICSDescription(String icsBody) throws IOException { protected String getICSDescription(String icsBody) throws IOException {
String description = getICSValue(icsBody, "DESCRIPTION:", ""); return 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;
} }
static class Participants { static class Participants {