strata / frontend

The front of Headless CMS. Build an efficient front-end website taking content from multiple data sources.
MIT License
13 stars 5 forks source link

Fix issue when ToC titles contain special HTML characters #97

Closed jean-gui closed 1 year ago

jean-gui commented 1 year ago

If titles contain special characters such as &, Strata throws the following exception in dev: An exception has been thrown during the rendering of a template ("Warning: Strata\Frontend\View\TableOfContents\HeadingCollection::buildListItems(): unterminated entity reference Industry Sponsor"). And produces empty items in prod.

This PR simply escapes that content.

simonrjones commented 1 year ago

@jean-gui I merged this, added a test. It seems only the heading value needs to be escaped (since the ID was OK) so I removed the htmlentities() from the heading link attribute to avoid unecessary code.

I hope this fixes https://github.com/w3c/w3c-website/issues/184

jean-gui commented 1 year ago

It does, thanks @simonrjones