2525use Sabre \VObject \Parameter ;
2626use Sabre \VObject \Property ;
2727use Sabre \VObject \Recur \EventIterator ;
28+ use function htmlspecialchars ;
2829
2930class 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