fix #172, properly handle newlines at export/import

This commit is contained in:
tibbi 2017-05-15 23:29:42 +02:00
parent ac9c91be33
commit 7a4f244897
2 changed files with 4 additions and 5 deletions

View File

@ -25,9 +25,8 @@ class IcsExporter {
out.writeLn(BEGIN_CALENDAR) out.writeLn(BEGIN_CALENDAR)
for (event in events) { for (event in events) {
out.writeLn(BEGIN_EVENT) out.writeLn(BEGIN_EVENT)
event.title.replace("\n", "\\n").let { if (it.isNotEmpty()) out.writeLn("$SUMMARY:$it") }
event.title.let { if (it.isNotEmpty()) out.writeLn("$SUMMARY:$it") } event.description.replace("\n", "\\n").let { if (it.isNotEmpty()) out.writeLn("$DESCRIPTION$it") }
event.description.let { if (it.isNotEmpty()) out.writeLn("$DESCRIPTION$it") }
event.importId?.let { if (it.isNotEmpty()) out.writeLn("$UID$it") } event.importId?.let { if (it.isNotEmpty()) out.writeLn("$UID$it") }
event.eventType.let { out.writeLn("$CATEGORIES${activity.dbHelper.getEventType(it)?.title}") } event.eventType.let { out.writeLn("$CATEGORIES${activity.dbHelper.getEventType(it)?.title}") }

View File

@ -64,9 +64,9 @@ class IcsImporter {
curEnd = curStart + decodeTime(duration) curEnd = curStart + decodeTime(duration)
} else if (line.startsWith(SUMMARY) && !isNotificationDescription) { } else if (line.startsWith(SUMMARY) && !isNotificationDescription) {
curTitle = line.substring(SUMMARY.length) curTitle = line.substring(SUMMARY.length)
curTitle = getTitle(curTitle) curTitle = getTitle(curTitle).replace("\\n", "\n")
} else if (line.startsWith(DESCRIPTION) && !isNotificationDescription) { } else if (line.startsWith(DESCRIPTION) && !isNotificationDescription) {
curDescription = line.substring(DESCRIPTION.length) curDescription = line.substring(DESCRIPTION.length).replace("\\n", "\n")
} else if (line.startsWith(UID)) { } else if (line.startsWith(UID)) {
curImportId = line.substring(UID.length) curImportId = line.substring(UID.length)
} else if (line.startsWith(RRULE)) { } else if (line.startsWith(RRULE)) {