More input checks

* check Android's DURATION, RRULE, RDATE, EXRULE, EXDATE values for empty strings before processing
* catch InvalidArgumentException on invalid RRULE values from Android
* add Depth: 0 to REPORT multi-get requests as required by CalDAV/CardDAV RFCs
* fix crash bug on multi-get responses without content (see issue #113)
pull/2/head
rfc2822 11 years ago
parent b35273a6d5
commit 15e8e20bad

@ -209,37 +209,38 @@ public class LocalCalendar extends LocalCollection<Event> {
// recurrence
try {
String duration = cursor.getString(18);
if (duration != null)
if (duration != null && !duration.isEmpty())
e.setDuration(new Duration(new Dur(duration)));
String strRRule = cursor.getString(10);
if (strRRule != null)
if (strRRule != null && !strRRule.isEmpty())
e.setRrule(new RRule(strRRule));
String strRDate = cursor.getString(11);
if (strRDate != null) {
if (strRDate != null && !strRDate.isEmpty()) {
RDate rDate = new RDate();
rDate.setValue(strRDate);
e.setRdate(rDate);
}
String strExRule = cursor.getString(12);
if (strExRule != null) {
if (strExRule != null && !strExRule.isEmpty()) {
ExRule exRule = new ExRule();
exRule.setValue(strExRule);
e.setExrule(exRule);
}
String strExDate = cursor.getString(13);
if (strExDate != null) {
if (strExDate != null && !strExDate.isEmpty()) {
// ignored, see https://code.google.com/p/android/issues/detail?id=21426
ExDate exDate = new ExDate();
exDate.setValue(strExDate);
e.setExdate(exDate);
}
} catch (ParseException ex) {
Log.e(TAG, "Couldn't parse recurrence rules, ignoring");
Log.w(TAG, "Couldn't parse recurrence rules, ignoring", ex);
} catch (IllegalArgumentException ex) {
Log.w(TAG, "Invalid recurrence rules, ignoring", ex);
}
// status

@ -23,7 +23,8 @@ public class HttpReport extends HttpEntityEnclosingRequestBase {
setURI(uri);
setHeader("Content-Type", "text/xml; charset=UTF-8");
setHeader("Depth", "0");
try {
setEntity(new StringEntity(entity, "UTF-8"));

@ -437,9 +437,7 @@ public class WebDavResource {
if (prop.addressbookDescription != null)
properties.put(Property.DESCRIPTION, prop.addressbookDescription.getDescription());
} else
properties.remove(Property.IS_ADDRESSBOOK);
}
if (prop.resourcetype.getCalendar() != null) {
properties.put(Property.IS_CALENDAR, "1");
@ -457,19 +455,18 @@ public class WebDavResource {
for (DavPropComp component : prop.supportedCalendarComponentSet.components)
referenced.supportedComponents.add(component.getName());
}
} else
referenced.properties.remove(Property.IS_CALENDAR);
}
}
if (prop.getctag != null)
referenced.properties.put(Property.CTAG, prop.getctag.getCTag());
properties.put(Property.CTAG, prop.getctag.getCTag());
if (prop.getetag != null)
referenced.properties.put(Property.ETAG, prop.getetag.getETag());
properties.put(Property.ETAG, prop.getetag.getETag());
if (prop.calendarData != null)
if (prop.calendarData != null && prop.calendarData.ical != null)
referenced.content = new ByteArrayInputStream(prop.calendarData.ical.getBytes());
else if (prop.addressData != null)
else if (prop.addressData != null && prop.addressData.vcard != null)
referenced.content = new ByteArrayInputStream(prop.addressData.vcard.getBytes());
}
}

Loading…
Cancel
Save