diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 0ad1941d816986d2866f0ac66cbe4f539e331614..f7677680c029e029b2446ee62cf2c65308988b2b 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 47311d68bae1e7feb130dfbcb0d61fe791ccfd79..d065773e5186cb456c1eb0aa70dbfcd709fecc6a 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); } /**