Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using tag-like strings in an ICS file #199

Open
takaram opened this issue Nov 18, 2024 · 0 comments
Open

Support using tag-like strings in an ICS file #199

takaram opened this issue Nov 18, 2024 · 0 comments

Comments

@takaram
Copy link

takaram commented Nov 18, 2024

What do you want to achieve?

Currently Ics::generate() calls strip_tags on the description text.

if ($link->description) {
$url[] = 'DESCRIPTION:'.$this->escapeString(strip_tags($link->description));
}

I understand it is because Google calendar (and maybe others) supports HTML tags in the description text of an event while iCalendar does not.
However, strip_tags removes all strings enclosed by <>. This means you cannot use any angle brackets in the description.

$ cat test.php
<?php

use Spatie\CalendarLinks\Generators\Ics;
use Spatie\CalendarLinks\Link;

require __DIR__ . '/vendor/autoload.php';

$link = Link::create('title', new DateTime, new DateTime)->description('This is a <test description>.');
$ics = new Ics([], ['format' => 'file']);

echo $ics->generate($link), "\n";
$ php test.php
BEGIN:VCALENDAR
VERSION:2.0
PRODID:Spatie calendar-links
BEGIN:VEVENT
UID:e91d06b8ce3f5bbe3c7ea6ea83fdcbf0
SUMMARY:title
DTSTAMP:20241118T070823Z
DTSTART:20241118T070823Z
DTEND:20241118T070823Z
DESCRIPTION:This is a .
END:VEVENT
END:VCALENDAR

Suggestion

I would appreciate if Ics class has an option to skip strip_tags, e.g. new Ics(['stripTags' => false]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant