Wrong entity encoding in story HTML

Created on 29 April 2024, 8 months ago
Updated 9 September 2024, 3 months ago

Problem/Motivation

We have a story with this parameter:

{"text":"Cat\u00e9gorie #2","url":"http:\/\/google.com"}

ServerController renders it like this:

<a href="http://google.com">Cat&Atilde;&copy;gorie #2</a>

Steps to reproduce

Here is our story:

{"title":"Components\/molecules\/navigation\/breadcrumb","parameters":{"server":{"url":"http:\/\/drupal.docksal.site\/storybook\/stories\/render"}},"stories":[{"args":{"breadcrumb":[{"text":"Homepage","url":"http:\/\/google.com"},{"text":"Cat\u00e9gorie #2","url":"http:\/\/google.com"},{"text":"Sous-cat\u00e9gorie avec un lien bcp plus long #3"}]},"parameters":{"server":{"id":"eyJwYXRoIjoidGhlbWVzXC9jdXN0b21cL2Zyb250XC9jb21wb25lbnRzXC9tb2xlY3VsZXNcL25hdmlnYXRpb25cL2JyZWFkY3J1bWJcL2JyZWFkY3J1bWIuc3Rvcmllcy50d2lnIiwiaWQiOiJkZWZhdWx0In0%3D"}},"name":"default"}]}

Proposed resolution

I think $dom->loadHTML() does not detect the encoding correctly.
Using Html::load() is a better practice and seems to fix the issue.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Storybook

Created by

🇫🇷France prudloff Lille

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024