Skip to content

Commit

Permalink
calendar - escape html on .ics file import
Browse files Browse the repository at this point in the history
  • Loading branch information
kevodwyer committed Nov 11, 2024
1 parent 9cfe0b9 commit bee3ac9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions assets/apps/calendar/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,17 +765,25 @@ function toMoment(iCalComp, icalDateTime) {
}
return moment.tz(icalDateTime.toJSDate(), normaliseTimeZoneName(icalDateTime.zone.tzid));
}
function escapeHtml(unsafe) { //https://stackoverflow.com/a/6234804
return unsafe
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
function unpackEvent(iCalComp, iCalEvent, fromImport, isSharedWithUs, calendarId) {
let event = new Object();
event['isAllDay'] = true;
let id = iCalEvent.getFirstPropertyValue('uid');
event['Id'] = id == null ? "" : id;
let title = iCalEvent.getFirstPropertyValue('summary');
event['title'] = title == null ? "" : title;
event['title'] = title == null ? "" : escapeHtml(title);
let description = iCalEvent.getFirstPropertyValue('description');
event['description'] = description == null ? "" : description;
event['description'] = description == null ? "" : escapeHtml(description);
let location = iCalEvent.getFirstPropertyValue('location');
event['location'] = location == null ? "" : location;
event['location'] = location == null ? "" : escapeHtml(location);
event['start'] = toMoment(iCalComp, iCalEvent.getFirstPropertyValue('dtstart'));
if (event['start'] != null) {
if (iCalEvent.getFirstPropertyValue('dtstart').toICALString().indexOf('T')>-1){
Expand Down

0 comments on commit bee3ac9

Please sign in to comment.