Filter enforcement and raw HTML output

Created on 16 June 2025, about 2 months ago

While testing the Markdown Easy module, I encountered two issues related to the "Limit allowed HTML tags" filter.

Issue 1: Enforced dependency

The documentation suggests that the "Limit allowed HTML tags and correct faulty HTML" filter is strongly recommended, but optional. For example, the filter tips state:

"The Markdown Easy filter should run before the 'Limit allowed HTML tags and correct faulty HTML' filter. It is strongly recommended to use these filters together."

However, the module currently enforces this dependency. Around line 85 in markdown_easy.module, the following condition prevents saving the text format unless the HTML filter is enabled:

if (!isset($subsequent['status']) || !$subsequent['status'] || ...)

Similarly, in the README.md (lines 10–12), it says:

"It is strongly suggested ..."

This behavior appears to contradict the documentation. For trusted content, like my personal blog, I would prefer not to enable HTML filtering. Requiring it feels overly restrictive, but maybe I'm missing something?

2) Validation error displays raw HTML

When the above validation fails, the error message displays literal HTML, like:

This is likely caused by calling ->render() on a translatable string (around lines 100 and 108). In Drupal form validation, error messages should remain as TranslatableMarkup objects or be cast with (string) to avoid triggering the render system unnecessarily. For reference, see comments #21 and #22 on 📌 Support additional extensions Active .

Proposed solution

  1. Remove the requirement to enable the HTML filter (make it truly optional), or clarify the documentation to reflect the enforced dependency. Consider validating filter weights only when both filters are enabled.
  2. Fix the raw HTML display by avoiding use of ->render() in form validation error messages.
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium Dries

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