Twig debug mode causes parse error in appendXML

Created on 29 November 2021, almost 3 years ago
Updated 27 July 2024, 4 months ago

Problem/Motivation

If Twig Debug mode is true in services.yml, glossify fails with the following error:

Warning: DOMDocumentFragment::appendXML(): Entity: line 4: parser error : Double hyphen within comment: in Drupal\glossify\GlossifyBase->parseTooltipMatch() (line 144 of modules/contrib/glossify/src/GlossifyBase.php).

This is due to the

<!-- TWIG DEBUG -->

comments added to the rendered abbreviation.

Steps to reproduce

  1. Set twig debug mode = true in services.yml
  2. Load a page with glossary content
  3. Notice the error

Proposed resolution

Strip comments from rendered glossary output.

πŸ› Bug report
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States draenen

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • πŸ‡ΊπŸ‡ΈUnited States inregards2pluto Michigan

    Just ran face first into this same issue on version 3.0.

  • πŸ‡ΊπŸ‡ΈUnited States inregards2pluto Michigan

    Applied patch and confirmed that it still works against version 3.0. I know this ticket was originally made against v2.0. Is there a way we could fork this fix against the 3.0 branch that doesn't involve making a duplicate issue ticket?

  • Status changed to Needs work 4 months ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @draenen could you please prepare a MR from the patch? And maybe it would be worth to link this issue in the comment?

    Are there better alternatives to this approach, maybe?

    This should be fixed in the 3.x version.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    We should also have a test for this. It should fail for now and work with the fix. Thank you!

Production build 0.71.5 2024