Twig debug mode causes parse error in appendXML

Created on 29 November 2021, over 3 years ago
Updated 30 April 2024, about 1 year 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 review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States draenen

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.

  • πŸ‡ΊπŸ‡Έ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 11 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!

  • Issue was unassigned.
  • Status changed to Postponed: needs info 3 months ago
  • πŸ‡©πŸ‡ͺGermany Grevil

    We are not using "appendXML" in the newest release anymore. Is this still a problem?

  • πŸ‡©πŸ‡ͺGermany Grevil

    Nope, can not reproduce this anymore.

Production build 0.71.5 2024