Issue #3606615: Enable term glossary strips style attributes and inline SVG

Fixes #3606615.

Cause

TermGlossaryHooks::preprocessField() replaced the field content with a plain-string #markup element:

$variables['items'][$key]['content'] = [
  '#type' => 'markup',
  '#markup' => $result['html'],
];

A plain-string #markup is run through Xss::filterAdmin() by core's Renderer::ensureMarkupIsSafe(). That filter strips style attributes (text color / font size from the Font CKEditor 5 plugin) and drops inline <svg> (UI icons) entirely, even though the field's text format allowed them. It only shows once a glossary term matches, since that is the only path that rebuilds the markup.

Fix

The HTML is already safe: it is the field's own rendered (text-format filtered) output with the term tags (rendered in isolation) spliced in. Wrap it in Markup::create() so the renderer does not re-filter it.

Test

Adds a functional regression test: with a glossary term present (so the replacement path runs), a body carrying a styled span and an inline SVG keeps both after the term is wrapped. Verified red before the fix (the style color is stripped) and green after.

Merge request reports

Loading