From 7a4f244897e7f66ce7e40f198e40ccc3073bfa3d Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 15 May 2017 23:29:42 +0200 Subject: [PATCH] fix #172, properly handle newlines at export/import --- .../com/simplemobiletools/calendar/helpers/IcsExporter.kt | 5 ++--- .../com/simplemobiletools/calendar/helpers/IcsImporter.kt | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt index 4b73236e3..67ec30ff9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt @@ -25,9 +25,8 @@ class IcsExporter { out.writeLn(BEGIN_CALENDAR) for (event in events) { out.writeLn(BEGIN_EVENT) - - event.title.let { if (it.isNotEmpty()) out.writeLn("$SUMMARY:$it") } - event.description.let { if (it.isNotEmpty()) out.writeLn("$DESCRIPTION$it") } + event.title.replace("\n", "\\n").let { if (it.isNotEmpty()) out.writeLn("$SUMMARY:$it") } + event.description.replace("\n", "\\n").let { if (it.isNotEmpty()) out.writeLn("$DESCRIPTION$it") } event.importId?.let { if (it.isNotEmpty()) out.writeLn("$UID$it") } event.eventType.let { out.writeLn("$CATEGORIES${activity.dbHelper.getEventType(it)?.title}") } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt index 2e4eccdea..f91e3f1ee 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt @@ -64,9 +64,9 @@ class IcsImporter { curEnd = curStart + decodeTime(duration) } else if (line.startsWith(SUMMARY) && !isNotificationDescription) { curTitle = line.substring(SUMMARY.length) - curTitle = getTitle(curTitle) + curTitle = getTitle(curTitle).replace("\\n", "\n") } else if (line.startsWith(DESCRIPTION) && !isNotificationDescription) { - curDescription = line.substring(DESCRIPTION.length) + curDescription = line.substring(DESCRIPTION.length).replace("\\n", "\n") } else if (line.startsWith(UID)) { curImportId = line.substring(UID.length) } else if (line.startsWith(RRULE)) {