The text format restricted_html is hardcoded in a couple of areas -- https://git.drupalcode.org/search?group_id=&project_id=59473&repository_... -- but may not be available on every site. For example, the Varbase distribution and varbase_editor specifically remove the restricted_html format.

Comments

mrP created an issue. See original summary.

tr’s picture

Status: Active » Postponed (maintainer needs more info)

Seems like more of a problem for the varbase profile - if it removes the restricted_html filter format, then how does it expect us to display user-entered markup in a secure manner?

mrP’s picture

Perhaps a user could choose the desired text format? With any D8 site, one could delete the restricted_html text format so Varbase is just an example imo.

tr’s picture

Priority: Normal » Minor
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new985 bytes

Here's a patch that adds the restricted_html filter when Rules is installed, if the filter doesn't already exist. Does this work for you?

As this is is used on an administration page to display rich text that might have been imported from a config file, I need a way to securely display the text without losing the markup. The restricted_html filter is exactly what I want here, especially for its ability to autolink URLs and to convert line breaks to paragraph tags. But because this is an administration page, I don't want or need to have this be a configurable filter - that would require configuration settings and a selection form on a settings page and some fallback filter, an HTML editor, etc. - way too much work for displaying one small block of text in a much larger table.

mrP’s picture

This looks like a perfectly reasonable approach to me. Perhaps make it restricted_html_rules so that it's clear that it's a text format required for rules to function. And if there is a way to prevent edit/delete to the text format, then even better. Just like restricted_html can be deleted, it can also be modified to where it may not satisfy rules requirements.

mrP’s picture

Status: Needs review » Needs work
tr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.33 KB

One of the purposes of doing it this way is so that Rules *doesn't* have to create and maintain its own filter, especially when a perfectly good one (restricted_html) is available on most sites. By making this an optional config which is a copy of the core restricted_html filter, it will be installed only if restricted_html is not present. There is no way to disable editing the filter on a site, but as with all filters if you change it or delete it you need to be ready for consequences all over your site. I don't see a need to treat restricted_html any differently.

Here's a new version of the patch where I've added some comments and added some dependencies to ensure this filter gets removed when Rules is uninstalled.

  • TR committed d42b6e5 on 8.x-3.x
    Issue #3119693 by TR: Missing text format: restricted_html
    
tr’s picture

Status: Needs review » Fixed

Committed #7.

Status: Fixed » Closed (fixed)

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

2dareis2do’s picture

Drupal 10.1.x I am getting this same warning when rules module is enabled.e.g

filter 19/10/2023 - 17:00 Disabled text format: restricted_html.

filtered_html does seem available not sure about filter_html