From 086f524bd1b14a356c0b8fe487e139a48c06e15c Mon Sep 17 00:00:00 2001 From: nod_ <nod_@598310.no-reply.drupal.org> Date: Wed, 5 Mar 2025 09:57:31 +0100 Subject: [PATCH] =?UTF-8?q?Issue=20#3492874=20by=20tar=5Finet,=20joshua123?= =?UTF-8?q?4511,=20smustgrave:=20<wbr>=20can=C2=B4t=20be=20used=20in=20tra?= =?UTF-8?q?nslations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/modules/locale/locale.module | 2 +- .../locale/tests/src/Kernel/LocaleStringIsSafeTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 0ad1941d8169..f7677680c029 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -712,7 +712,7 @@ function locale_string_is_safe($string) { // string. https://www.drupal.org/node/2372127 $string = preg_replace('/\[[a-z0-9_-]+(:[a-z0-9_-]+)+\]/i', '', $string); - return Html::decodeEntities($string) == Html::decodeEntities(Xss::filter($string, ['a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var'])); + return Html::decodeEntities($string) == Html::decodeEntities(Xss::filter($string, ['a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var', 'wbr'])); } /** diff --git a/core/modules/locale/tests/src/Kernel/LocaleStringIsSafeTest.php b/core/modules/locale/tests/src/Kernel/LocaleStringIsSafeTest.php index 47311d68bae1..d065773e5186 100644 --- a/core/modules/locale/tests/src/Kernel/LocaleStringIsSafeTest.php +++ b/core/modules/locale/tests/src/Kernel/LocaleStringIsSafeTest.php @@ -45,6 +45,11 @@ public function testLocaleStringIsSafe(): void { $string = 'Hi <a href="[current-user:url]">user</a>'; $result = locale_string_is_safe($string); $this->assertTrue($result); + + // Check a translatable string which includes a wbr tag. + $string = 'DrupalLocaleModule<wbr>Test<wbr>Example'; + $result = locale_string_is_safe($string); + $this->assertTrue($result); } /** -- GitLab