BEMADEV / Room-Management

1 stars 2 forks source link

Download .ics button breaks on special characters #23

Closed matthewmeekins closed 1 year ago

matthewmeekins commented 1 year ago

Please go through all the tasks below

Please provide a brief description of the problem. Please do not forget to attach the relevant screenshots from your side.

When there is a reservation name or a location name with an apostrophe, the download .ics button doesn't generate a file, it just reloads the page.

I fixed this temporarily by adding and Escape filter to the script in the ReservationDetail.ascx.cs file:

<script>function ics_click() { text ={{ Reservation.Schedule.iCalendarContent }}.replace('END:VEVENT', 'SUMMARY: {{ Reservation.Name | Escape }}\r\nLOCATION: {{ Reservation.ReservationLocations | Select:'Location' | Select:'Name' | Join:', ' | Escape }}\r\nEND:VEVENT'); var element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); element.setAttribute('download', '{{ Reservation.Name | Escape }}.ics'); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); } </script>

It's not beautiful, but it's better than the button not working.

Expected Behavior

I expect the download button to work for any reservation or location.

Actual Behavior

The button does not work when there are special characters in the reservation name or location.

Steps to Reproduce

  1. Create reservation with a name that has an apostrophe, i.e. "Women's Event".
  2. Click the download .ics button in the bottom right. image

Rock Version

15.1

Plugin Version

2.3.9.14

Client Culture Setting

en-US

tcavaletto commented 1 year ago

Included in Release 2.4.3.14