From 76ced7915b56ff956fb83c74486d2f3a4f83d96f Mon Sep 17 00:00:00 2001 From: mguessan Date: Fri, 6 Aug 2010 21:21:13 +0000 Subject: [PATCH] Caldav: skip empty lines git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1327 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/VObject.java | 19 +++++++++++-------- .../exchange/TestExchangeSessionEvent.java | 11 +++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/java/davmail/exchange/VObject.java b/src/java/davmail/exchange/VObject.java index 2fafad1b..08cb21ce 100644 --- a/src/java/davmail/exchange/VObject.java +++ b/src/java/davmail/exchange/VObject.java @@ -86,12 +86,15 @@ public class VObject { protected void handleLine(String line, BufferedReader reader) throws IOException { - VProperty property = new VProperty(line); - // inner object - if ("BEGIN".equals(property.getKey())) { - addVObject(new VObject(property, reader)); - } else { - addProperty(property); + // skip empty lines + if (line.length() > 0) { + VProperty property = new VProperty(line); + // inner object + if ("BEGIN".equals(property.getKey())) { + addVObject(new VObject(property, reader)); + } else if (property.getKey() != null) { + addProperty(property); + } } } @@ -151,7 +154,7 @@ public class VObject { public VProperty getProperty(String name) { if (properties != null) { for (VProperty property : properties) { - if (property.getKey().equalsIgnoreCase(name)) { + if (property.getKey() != null && property.getKey().equalsIgnoreCase(name)) { return property; } } @@ -164,7 +167,7 @@ public class VObject { List result = null; if (properties != null) { for (VProperty property : properties) { - if (property.getKey().equalsIgnoreCase(name)) { + if (property.getKey() != null && property.getKey().equalsIgnoreCase(name)) { if (result == null) { result = new ArrayList(); } diff --git a/src/test/davmail/exchange/TestExchangeSessionEvent.java b/src/test/davmail/exchange/TestExchangeSessionEvent.java index 2f7a0727..6f8109cc 100644 --- a/src/test/davmail/exchange/TestExchangeSessionEvent.java +++ b/src/test/davmail/exchange/TestExchangeSessionEvent.java @@ -251,4 +251,15 @@ public class TestExchangeSessionEvent extends TestCase { assertTrue(toClient.contains("EXDATE;TZID=\"Europe/Paris\":20100823T150000")); } + + public void testEmptyLine() throws IOException { + String itemBody = "BEGIN:VCALENDAR\n" + + "BEGIN:VEVENT\n" + + "\n" + + "END:VEVENT\n" + + "END:VCALENDAR"; + String toClient = fixICS(itemBody, true); + System.out.println(toClient); + } + }