Issue when linking to content with ampersands or single quotes in the title

Created on 25 June 2018, over 6 years ago
Updated 25 August 2023, over 1 year ago

Problem/Motivation

The suggestion label and descriptions are HTML-escaped in the matcher plugins. This becomes an issue when the values are then used in the user interface other than the LinkIt suggestion list. For example in Linkit for Link field Fixed the label is injected into the Title for a Link field.

As a result, the URL Title displays escaped html entities:

Steps to reproduce

  1. Install Drupal Standard and enable LinkIt
  2. Create a basic page with title "Liberté, Égalité & Fraternité"
  3. Notice the & is escaped in the autocomplete suggestion at /linkit/autocomplete/default?q=Libert

Proposed resolution

Remove HTML escaping from the matcher plugins. Implement HTML escaping when displaying the suggestions instead.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

Matcher suggestions in the autocomplete json are no longer html escaped.

Original report by idflood

When inserting link in wysiwyg I had an issue with pages having a "&" in title.

To reproduce you can create a page with the title "Bugs & issues" for example, and then on another page you can try to link to it from the wysiwyg:
- When you click on the suggestion the textfield will get "Bugs & issues"
- When you submit and inspect the source of the wysiwyg you will notice that the only has the href attributes (and the href is equal to the title with the &).

The following patch only decode html entities for the entity label and fixes the issue locally.

🐛 Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

🇨🇭Switzerland idflood

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024