Commit fb1b714e authored by Ricki Hirner's avatar Ricki Hirner

Ignore invalid DUE before DTSTART

parent a37d6070
Pipeline #4579840 passed with stage
in 7 minutes and 40 seconds
image: registry.gitlab.com/bitfireat/davdroid:latest
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- chmod +x gradlew
- export GRADLE_USER_HOME=`pwd`/.gradle; chmod +x gradlew
- emulator64-arm -avd test -no-skin -no-audio -no-window & wait-for-emulator.sh
- wget https://f-droid.org/repo/org.dmfs.tasks_103.apk && adb install org.dmfs.tasks_103.apk
- wget -q https://f-droid.org/repo/org.dmfs.tasks_103.apk && adb install org.dmfs.tasks_103.apk
cache:
paths:
......@@ -13,7 +12,7 @@ cache:
test:
script:
- ./gradlew -i check connectedCheck
- ./gradlew check connectedCheck
artifacts:
paths:
- build/outputs/lint-results-debug.html
......
......@@ -113,6 +113,22 @@ public class AndroidTaskTest extends InstrumentationTestCase {
assertEquals(task.dtStart, task2.dtStart);
}
public void testAddTaskWithInvalidDue() throws ParseException, CalendarStorageException, FileNotFoundException {
Task task = new Task();
task.uid = "invalidDUE@ical4android.tests";
task.summary = "Task with invalid DUE";
task.dtStart = new DtStart(new Date("20150102"));
task.due = new Due(new Date("20150101"));
Uri uri = new TestTask(taskList, task).add();
assertNotNull("Couldn't add task", uri);
@Cleanup("delete") TestTask testTask = new TestTask(taskList, ContentUris.parseId(uri));
assertNotNull("Inserted task is not here", testTask);
Task task2 = testTask.getTask();
assertNull(task.due);
}
public void testUpdateTask() throws URISyntaxException, ParseException, FileNotFoundException, CalendarStorageException {
// add test event without reminder
Task task = new Task();
......
......@@ -318,6 +318,12 @@ public abstract class AndroidTask {
builder.withValue(Tasks.CREATED, task.createdAt);
builder.withValue(Tasks.LAST_MODIFIED, task.lastModified);
if (task.dtStart != null && task.due != null && task.due.getDate().before(task.dtStart.getDate())) {
// there seem to be many invalid tasks out there because of some defect clients
Constants.log.warning("Invalid DUE before DTSTART; ignoring");
task.due = null;
}
builder.withValue(Tasks.DTSTART, task.dtStart != null ? task.dtStart.getDate().getTime() : null);
builder.withValue(Tasks.DUE, task.due != null ? task.due.getDate().getTime() : null);
builder.withValue(Tasks.DURATION, task.duration != null ? task.duration.getValue() : null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment