From e993559873b07c6da0a2d101fe073e068e894ab5 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 2 Oct 2020 09:19:18 +0100 Subject: [PATCH] [ML] Improve calendar ics file parsing (#78986) (#79125) --- .../settings/calendars/edit/import_modal/utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/import_modal/utils.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/import_modal/utils.js index 07bf49ea6d7db..e93abc8eb67b5 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/import_modal/utils.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/import_modal/utils.js @@ -42,7 +42,10 @@ export function filterEvents(events) { } export function parseICSFile(data) { - const cal = icalendar.parse_calendar(data); + // force a new line char on the end of the data + // icalendar must split on new lines and so parsing fails + // if there isn't at least one new line at the end. + const cal = icalendar.parse_calendar(data + '\n'); return createEvents(cal); }