Problem/Motivation

Tab titles containing special characters such as "&" are rendered as literal "&" in the browser instead of the intended character. The issue is a double HTML-encoding chain in QuickTabs.php.

Steps to reproduce

1. Create a Quicktabs instance with a tab title that contains an ampersand, e.g. Meetings & Events.
2. Place the block on a page and view it.
3. Observe the tab label renders as "Meetings & Events" instead of "Meetings & Events".

Proposed resolution

Remove the t('@title', ...) wrapper (stored tab titles are not translatable strings) and wrap the Xss::filter() result in Markup::create() so that Link::fromTextAndUrl() recognizes it as already-sanitized HTML. Also add the required "use Drupal\Core\Render\Markup;" statement.

User interface changes

Tab titles with special characters (&, <, >, quotes) will now render correctly instead of showing escaped HTML entities.

Comments

lucuella created an issue. See original summary.

lucuella’s picture

StatusFileSize
new780 bytes

Attaching patch against 4.1.0. The fix removes the t('@title', [...]) wrapper that was causing the first encoding pass, and wraps the Xss::filter() result in Markup::create() so Link::fromTextAndUrl() does not escape it a second time.

lucuella’s picture

Status: Active » Needs review