Fix parser errors that can occur when rendered tooltip contains certain characters like  

Created on 12 February 2025, about 2 months ago

Problem/Motivation

In πŸ› DOMDocumentFragment::appendXML(): Entity: line 1: parser error : EntityRef: expecting ';' in Drupal\glossify\GlossifyBase->parseTooltipMatch() Needs work we fixed some issues related to DOM Document parse errors, but it was identified that the use of DOMDocumentFragment::appendXML was not correct. We use that method when re-inserting matched glossary that we aren't modifying and when inserting a rendered tooltip or link for the matched term.

appendXML requires the input be valid XML, but we are dealing with text and HTML which may contain characters that are not valid in XML, like  . For example, having that in the rendered tooltip will cause parse warnings and the output won't be correct.

Steps to reproduce

Configure the module to render a tooltip for matched glossary terms, and create a glossary taxonomy term that contains   in its description. Then create a node with text format configured with glossify and include the matched term. Observe the parser errors when viewing the node.

Proposed resolution

Don't use appendXML. Create a temporary HTML DOM document from the content we want to insert, then import the the node(s) from that into the main document. This ensures we're dealing with HTML and not XML.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

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