Serve ical with CRLF instead LF


#1

I’m serving a ics file with events using a events.ics.twig file. The file it self is generated, but when I validate the file on https://icalendar.org/validator.html it says that there are missing CRLF. When I download the file on open it in vscode it shows LF although the twig template itself is stored as CRLF. While digging deeper into this topic, it seems that twig always renders LF (https://github.com/twigphp/Twig/issues/1481). Does someone have an idea to solve this issue? I want to serve valid ical files.
Can I write a plugin to replace \n in “twigged” output with \r\n?
Appreciate your help!


#2

You could try to post process the ical file in the onOutputRendered event. This requires a custom plugin though.