1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 11:12:22 -05:00

Caldav: fix nullpointer in VCalendar on missing DTEND

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1494 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-10-05 22:23:35 +00:00
parent 4df643eea1
commit 533b627b2b
2 changed files with 32 additions and 27 deletions

View File

@ -259,27 +259,29 @@ public class VCalendar extends VObject {
}
protected void setClientAllday(VProperty property) {
// set VALUE=DATE param
if (!property.hasParam("VALUE")) {
property.addParam("VALUE", "DATE");
}
// remove TZID
property.removeParam("TZID");
String value = property.getValue();
if (value.length() != 8) {
// try to convert datetime value to date value
try {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateParser = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
calendar.setTime(dateParser.parse(value));
calendar.add(Calendar.HOUR_OF_DAY, 12);
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd");
value = dateFormatter.format(calendar.getTime());
} catch (ParseException e) {
LOGGER.warn("Invalid date value in allday event: " + value);
if (property != null) {
// set VALUE=DATE param
if (!property.hasParam("VALUE")) {
property.addParam("VALUE", "DATE");
}
// remove TZID
property.removeParam("TZID");
String value = property.getValue();
if (value.length() != 8) {
// try to convert datetime value to date value
try {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateParser = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
calendar.setTime(dateParser.parse(value));
calendar.add(Calendar.HOUR_OF_DAY, 12);
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd");
value = dateFormatter.format(calendar.getTime());
} catch (ParseException e) {
LOGGER.warn("Invalid date value in allday event: " + value);
}
}
property.setValue(value);
}
property.setValue(value);
}
protected void fixAlarm(VObject vObject, boolean fromServer) {

View File

@ -294,14 +294,17 @@ public class TestExchangeSessionEvent extends TestCase {
"PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" +
"VERSION:2.0\n" +
"BEGIN:VEVENT\n" +
"CREATED:20100916T115132Z\n" +
"LAST-MODIFIED:20100916T115138Z\n" +
"DTSTAMP:20100916T115138Z\n" +
"UID:d72ff8cc-f3ee-4fbc-b44d-1aaf78d92847\n" +
"SUMMARY:New Event\n" +
"DTSTART;VALUE=DATE:20100929\n" +
"DTEND;VALUE=DATE:20100930\n" +
"TRANSP:TRANSPARENT\n" +
"CREATED:20090906T141628Z\n" +
"LAST-MODIFIED:20090906T141630Z\n" +
"DTSTAMP:20090820T162854Z\n" +
"UID:20090820T182854CEST-774934hSZ6@education.gouv.fr\n" +
"SUMMARY:Rentrée scolaire des enseignants - Zone C\n" +
"DTSTART;TZID=\"null\":20080901T000000\n" +
"DESCRIPTION:Rentrée scolaire des enseignants\n" +
"LOCATION:France\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n" +
"X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\n" +
"ORGANIZER:MAILTO:laurent.bazin@chu-bordeaux.fr\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
String toServer = fixICS(itemBody, true);