Followup to #3410145: Paragraph tags are not stripped if the p tag has attributes like dir=ltr or title

Problem/Motivation

By using DOMDocument::loadHTML(), we might raise a lot of warnings because it's not supporting HTML5 markup (as stated in the documentation comments). Drupal Core fixed this by relying on the HTML5-PHP library instead of directly using DOMDocument.

Steps to reproduce

  1. Configure this filter on a text format
  2. Allow source editing and allow any HTML5 tag (ie. <mark>)
  3. Create a content using the allowed tag
  4. Display the content

Proposed resolution

Use Drupal Core's HTML::load() instead of our custom DOMDocument implementation so people using Drupal 10.2.x won't have warnings anymore.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

DuaelFr created an issue. See original summary.

duaelfr’s picture

Status: Active » Needs review
mlncn’s picture

Version: 1.x-dev » 1.0.x-dev
Status: Needs review » Reviewed & tested by the community

Very nice, looks good.

We really should have had tests in place to ensure it still does what it is supposed to do but manual check and the code looks good.

  • mlncn committed b84b67d5 on 1.0.x
    Issue #3427854 by duaelfr, mlncn: Warnings when using this on HTML5...
mlncn’s picture

Status: Reviewed & tested by the community » Fixed

Hi duaelfr i missed your offer in #3410145: Paragraph tags are not stripped if the p tag has attributes like dir=ltr or title to help maintain— ridiculously belatedly, i have added you as a maintainer.

Since in that issue you fixed the character encoding issues i trust that you (and, y'know, the Drupal core team) are confident that this is not a regression there.

Thanks again!

Side note: Releases have always been made against the 1.0.x branch and i have made the 1.x branch not the default in git.drupalcode now, i'll try to archive it but let's ignore it and be sure we are on 1.0.x from now on.

  • mlncn committed d8be32e2 on 1.0.x
    Issue #3427854 Update minimum required version of Drupal core for...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.