From fc8d335ea29f11fd8984df9cd67cde304fb5739a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 4 Jun 2023 23:10:56 +0200 Subject: [PATCH] Fix ics escaping and IDs --- resources/views/api/ical.twig | 14 ++++++++------ src/Controllers/FeedController.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/resources/views/api/ical.twig b/resources/views/api/ical.twig index 3b0d20a1..7c4942fd 100644 --- a/resources/views/api/ical.twig +++ b/resources/views/api/ical.twig @@ -1,8 +1,8 @@ {% set dateFormat = 'Ymd\\THis\\Z' %} -{% set replacement = {'\n': '\\n'} %} +{% set replacement = {'\\': '\\\\', ';': '\\;', ',': '\\,', '\n': '\\n'} %} BEGIN:VCALENDAR VERSION:2.0 -PRODID:-//-/{{ config('app_name') }}//DE +PRODID:-//-/{{ config('app_name') | replace(replacement) | raw }}//DE CALSCALE:GREGORIAN {% for entry in shiftEntries %} BEGIN:VEVENT @@ -12,12 +12,14 @@ DTSTART:{{ entry.shift.start.utc().format(dateFormat) }} DTEND:{{ entry.shift.end.utc().format(dateFormat) }} STATUS:CONFIRMED TRANSP:OPAQUE -SUMMARY:{{ entry.shift.shiftType.name ~ ' (' ~ entry.shift.title ~ ')' | replace(replacement) | raw }} +SUMMARY:{{ (entry.shift.shiftType.name ~ ' (' ~ entry.shift.title ~ ')') | replace(replacement) | raw }} LOCATION:{{ entry.shift.room.name | replace(replacement) | raw }} DESCRIPTION:{{ - entry.shift.shiftType.description - ~ '\\n' ~ entry.shift.description - ~ '\\n' ~ entry.user_comment + ( + entry.shift.shiftType.description + ~ '\n' ~ entry.shift.description + ~ '\n' ~ entry.user_comment + ) | replace(replacement) | raw }} URL:{{ url('/shifts', {'action': 'view', 'shift_id': entry.shift.id}) | raw }} diff --git a/src/Controllers/FeedController.php b/src/Controllers/FeedController.php index 24ee2ec8..11885215 100644 --- a/src/Controllers/FeedController.php +++ b/src/Controllers/FeedController.php @@ -152,6 +152,6 @@ class FeedController extends BaseController ->leftJoin('shifts', 'shifts.id', 'shift_entries.shift_id') ->orderBy('shifts.start') ->with(['shift', 'shift.room', 'shift.shiftType']) - ->get(); + ->get(['*', 'shift_entries.id']); } }