Decode HTML Entities for Title and Description in iCal Expor

Created on 3 October 2023, 12 months ago
Updated 5 October 2023, 12 months ago

Problem/Motivation

The iCal export functionality in the ServiceController currently does not decode HTML entities for the title and description fields. This can result in issues when these fields contain HTML-encoded characters, such as apostrophes and quotes.

Steps to reproduce

1. Export an event with a title or description containing HTML-encoded characters, such as ’ for apostrophes.
2. Download the exported iCal file.
3. Observe that the special characters are not properly decoded in the iCal event.

Proposed resolution

This issue proposes to decode HTML entities in the title and description fields using the `html_entity_decode` function before setting them in the iCal event object. This change will ensure that special characters are correctly displayed in the exported iCal data.

**Code Changes:**

protected function createEvent(array $field_settings, \DateTime $dtStart, \DateTime $dtEnd, bool $noTime = FALSE) {
  $event = new Event();

  // Decode HTML entities in the title and description
  $decodedTitle = html_entity_decode($field_settings['title'], ENT_QUOTES, 'UTF-8');
  $decodedDescription = html_entity_decode($field_settings['description'], ENT_QUOTES, 'UTF-8');

  $event->setSummary($decodedTitle);
  $event->setDescription($decodedDescription);
  $event->setLocation($field_settings['location']);
  $event->setNoTime($noTime);
  $event->setDtStart($dtStart);
  $event->setDtEnd($dtEnd);
  return $event;
}

Remaining tasks

Implement the proposed code changes to decode HTML entities.
Test the modified iCal export functionality to ensure that HTML entities are correctly decoded.
Document the changes in the codebase and update any relevant documentation.

User interface changes

There are no user interface changes associated with this issue.

API changes

There are no API changes associated with this issue.

Data model changes

There are no data model changes associated with this issue.

🐛 Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇫🇷France perpignan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024