Disabled tags not ignored when having child elements

Created on 2 May 2024, 8 months ago
Updated 22 May 2024, 7 months ago

Problem/Motivation

The disable tags logic is not working for some specific, nested HTML snippets (similar issue: https://www.drupal.org/project/onomasticon/issues/3283335 🐛 Disabled logic is not working as expected Closed: works as designed ).

Example of not working snippet:

<ul>
    <li>
        <a><strong>TERM</strong> TERM</a>
    </li>
</ul>

The second term (not within the <strong> tag will have a glossary link, even though the term is inside a <a> tag.

I tested multiple variations of this snippet. The issue does NOT occur when:

  • <ul> and <li> tags are replaced by e.g. a single <p>tag
  • Terms only occur directly within the <a> tag (without <strong>) or only within <a><strong> (no text directly within the <a> element)
  • the order is switched to <a>TERM <strong>TERM</strong><a>

The issue occurs if both terms are the same but also with two different terms.

Steps to reproduce

  • Install and enable onomoasticon
  • Configure a text format to use the onomasticon filter (the <a> tag is disabled by default)
  • Add the example code snippet to a text field using the text format with the onomasticon filter
  • Save the page and check the text field content. The second term (not within the <strong> tag) will have a glossary link.

Proposed resolution

For this code snippet, the <a> tag is stripped, before the second term is being processed. This happens in the processChildren() function, when the end of the branch is reached.

🐛 Bug report
Status

Fixed

Version

2.2

Component

Code

Created by

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