Problem/Motivation

A translation sting can have a <br /> tag but <br/> (without the space) fails the check in locale_string_is_safe.

The problem arises because Xss::filter reassembles the html with the one space.

Steps to reproduce

The real use case is described in #3538468: Please consider removing <br/> tags from translatable strings to avoid import errors

or check:

locale_string_is_safe('hello<br/>drupal'); // FALSE
locale_string_is_safe('hello<br />drupal'); // TRUE
locale_string_is_safe('hello<br  />drupal'); // FALSE

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3586472

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

bircher created an issue. See original summary.

bircher’s picture

Status: Active » Needs review

We can just disregard spaces when doing the comparison between the filtered and non filtered version of the string.

bircher’s picture

Issue tags: +DevDaysAthens2026
dcam’s picture

Status: Needs review » Needs work

I left a few suggestions on the MR. The change to the anonymous function is kind of a subjective code-style change. Take it or leave it. But I do feel like the comment move is appropriate. Please consider them.