Skip to content

Commit 0ff293b

Browse files
authored
Merge pull request #56965 from nextcloud/backport/56925/stable32
2 parents d229850 + 38df058 commit 0ff293b

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,31 @@ private function addBulletList(IEMailTemplate $template,
142142
IL10N $l10n,
143143
string $calendarDisplayName,
144144
VEvent $vevent):void {
145-
$template->addBodyListItem($calendarDisplayName, $l10n->t('Calendar:'),
146-
$this->getAbsoluteImagePath('actions/info.png'));
145+
$template->addBodyListItem(
146+
htmlspecialchars($calendarDisplayName),
147+
$l10n->t('Calendar:'),
148+
$this->getAbsoluteImagePath('actions/info.png'),
149+
htmlspecialchars($calendarDisplayName),
150+
);
147151

148152
$template->addBodyListItem($this->generateDateString($l10n, $vevent), $l10n->t('Date:'),
149153
$this->getAbsoluteImagePath('places/calendar.png'));
150154

151155
if (isset($vevent->LOCATION)) {
152-
$template->addBodyListItem((string)$vevent->LOCATION, $l10n->t('Where:'),
153-
$this->getAbsoluteImagePath('actions/address.png'));
156+
$template->addBodyListItem(
157+
htmlspecialchars((string)$vevent->LOCATION),
158+
$l10n->t('Where:'),
159+
$this->getAbsoluteImagePath('actions/address.png'),
160+
htmlspecialchars((string)$vevent->LOCATION),
161+
);
154162
}
155163
if (isset($vevent->DESCRIPTION)) {
156-
$template->addBodyListItem((string)$vevent->DESCRIPTION, $l10n->t('Description:'),
157-
$this->getAbsoluteImagePath('actions/more.png'));
164+
$template->addBodyListItem(
165+
htmlspecialchars((string)$vevent->DESCRIPTION),
166+
$l10n->t('Description:'),
167+
$this->getAbsoluteImagePath('actions/more.png'),
168+
htmlspecialchars((string)$vevent->DESCRIPTION),
169+
);
158170
}
159171
}
160172

apps/dav/lib/CalDAV/Schedule/IMipService.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Sabre\VObject\Parameter;
2626
use Sabre\VObject\Property;
2727
use Sabre\VObject\Recur\EventIterator;
28+
use function htmlspecialchars;
2829

2930
class IMipService {
3031

@@ -80,10 +81,11 @@ private function generateDiffString(VEvent $vevent, VEvent $oldVEvent, string $p
8081
if (!isset($vevent->$property)) {
8182
return $default;
8283
}
83-
$newstring = $vevent->$property->getValue();
84+
$value = $vevent->$property->getValue();
85+
$newstring = $value === null ? null : htmlspecialchars($value);
8486
if (isset($oldVEvent->$property) && $oldVEvent->$property->getValue() !== $newstring) {
8587
$oldstring = $oldVEvent->$property->getValue();
86-
return sprintf($strikethrough, $oldstring, $newstring);
88+
return sprintf($strikethrough, htmlspecialchars($oldstring), $newstring);
8789
}
8890
return $newstring;
8991
}
@@ -95,9 +97,9 @@ private function generateLinkifiedDiffString(VEvent $vevent, VEvent $oldVEvent,
9597
if (!isset($vevent->$property)) {
9698
return $default;
9799
}
98-
/** @var string|null $newString */
99-
$newString = $vevent->$property->getValue();
100-
$oldString = isset($oldVEvent->$property) ? $oldVEvent->$property->getValue() : null;
100+
$value = $vevent->$property->getValue();
101+
$newString = $value === null ? null : htmlspecialchars($value);
102+
$oldString = isset($oldVEvent->$property) ? htmlspecialchars($oldVEvent->$property->getValue()) : null;
101103
if ($oldString !== $newString) {
102104
return sprintf(
103105
"<span style='text-decoration: line-through'>%s</span><br />%s",
@@ -797,10 +799,10 @@ public function buildCancelledBodyData(VEvent $vEvent): array {
797799
$strikethrough = "<span style='text-decoration: line-through'>%s</span>";
798800

799801
$newMeetingWhen = $this->generateWhenString($eventReaderCurrent);
800-
$newSummary = isset($vEvent->SUMMARY) && (string)$vEvent->SUMMARY !== '' ? (string)$vEvent->SUMMARY : $this->l10n->t('Untitled event');
801-
$newDescription = isset($vEvent->DESCRIPTION) && (string)$vEvent->DESCRIPTION !== '' ? (string)$vEvent->DESCRIPTION : $defaultVal;
802+
$newSummary = htmlspecialchars(isset($vEvent->SUMMARY) && (string)$vEvent->SUMMARY !== '' ? (string)$vEvent->SUMMARY : $this->l10n->t('Untitled event'));
803+
$newDescription = htmlspecialchars(isset($vEvent->DESCRIPTION) && (string)$vEvent->DESCRIPTION !== '' ? (string)$vEvent->DESCRIPTION : $defaultVal);
802804
$newUrl = isset($vEvent->URL) && (string)$vEvent->URL !== '' ? sprintf('<a href="%1$s">%1$s</a>', $vEvent->URL) : $defaultVal;
803-
$newLocation = isset($vEvent->LOCATION) && (string)$vEvent->LOCATION !== '' ? (string)$vEvent->LOCATION : $defaultVal;
805+
$newLocation = htmlspecialchars(isset($vEvent->LOCATION) && (string)$vEvent->LOCATION !== '' ? (string)$vEvent->LOCATION : $defaultVal);
804806
$newLocationHtml = $this->linkify($newLocation) ?? $newLocation;
805807

806808
$data = [];
@@ -1067,30 +1069,30 @@ public function addAttendees(IEMailTemplate $template, VEvent $vevent) {
10671069
*/
10681070
public function addBulletList(IEMailTemplate $template, VEvent $vevent, $data) {
10691071
$template->addBodyListItem(
1070-
$data['meeting_title_html'] ?? $data['meeting_title'], $this->l10n->t('Title:'),
1072+
$data['meeting_title_html'] ?? htmlspecialchars($data['meeting_title']), $this->l10n->t('Title:'),
10711073
$this->getAbsoluteImagePath('caldav/title.png'), $data['meeting_title'], '', IMipPlugin::IMIP_INDENT);
10721074
if ($data['meeting_when'] !== '') {
1073-
$template->addBodyListItem($data['meeting_when_html'] ?? $data['meeting_when'], $this->l10n->t('When:'),
1075+
$template->addBodyListItem($data['meeting_when_html'] ?? htmlspecialchars($data['meeting_when']), $this->l10n->t('When:'),
10741076
$this->getAbsoluteImagePath('caldav/time.png'), $data['meeting_when'], '', IMipPlugin::IMIP_INDENT);
10751077
}
10761078
if ($data['meeting_location'] !== '') {
1077-
$template->addBodyListItem($data['meeting_location_html'] ?? $data['meeting_location'], $this->l10n->t('Location:'),
1079+
$template->addBodyListItem($data['meeting_location_html'] ?? htmlspecialchars($data['meeting_location']), $this->l10n->t('Location:'),
10781080
$this->getAbsoluteImagePath('caldav/location.png'), $data['meeting_location'], '', IMipPlugin::IMIP_INDENT);
10791081
}
10801082
if ($data['meeting_url'] !== '') {
1081-
$template->addBodyListItem($data['meeting_url_html'] ?? $data['meeting_url'], $this->l10n->t('Link:'),
1083+
$template->addBodyListItem($data['meeting_url_html'] ?? htmlspecialchars($data['meeting_url']), $this->l10n->t('Link:'),
10821084
$this->getAbsoluteImagePath('caldav/link.png'), $data['meeting_url'], '', IMipPlugin::IMIP_INDENT);
10831085
}
10841086
if (isset($data['meeting_occurring'])) {
1085-
$template->addBodyListItem($data['meeting_occurring_html'] ?? $data['meeting_occurring'], $this->l10n->t('Occurring:'),
1087+
$template->addBodyListItem($data['meeting_occurring_html'] ?? htmlspecialchars($data['meeting_occurring']), $this->l10n->t('Occurring:'),
10861088
$this->getAbsoluteImagePath('caldav/time.png'), $data['meeting_occurring'], '', IMipPlugin::IMIP_INDENT);
10871089
}
10881090

10891091
$this->addAttendees($template, $vevent);
10901092

10911093
/* Put description last, like an email body, since it can be arbitrarily long */
10921094
if ($data['meeting_description']) {
1093-
$template->addBodyListItem($data['meeting_description_html'] ?? $data['meeting_description'], $this->l10n->t('Description:'),
1095+
$template->addBodyListItem($data['meeting_description_html'] ?? htmlspecialchars($data['meeting_description']), $this->l10n->t('Description:'),
10941096
$this->getAbsoluteImagePath('caldav/description.png'), $data['meeting_description'], '', IMipPlugin::IMIP_INDENT);
10951097
}
10961098
}

0 commit comments

Comments
 (0)