Skip to content

[K7.0] Fix double-encoded entities in topic meta description tags#10123

Open
genr8r wants to merge 1 commit into
Kunena:K7.0from
genr8r:K7.0_meta_description_double_encode
Open

[K7.0] Fix double-encoded entities in topic meta description tags#10123
genr8r wants to merge 1 commit into
Kunena:K7.0from
genr8r:K7.0_meta_description_double_encode

Conversation

@genr8r

@genr8r genr8r commented Jun 19, 2026

Copy link
Copy Markdown

Summary

A topic's meta description and Open Graph / Twitter card tags double-encode HTML entities. The visible post body is fine; only the <meta> tags are affected, which degrades search snippets and social-share previews.

Steps to reproduce

  1. On any Joomla version, create a forum topic whose first post contains a double quote in the first ~160 characters, e.g. Sites can show "not secure" warnings.
  2. Open the topic and View Source.
  3. The meta tags render:
    <meta name="description" content="Sites can show &amp;quot;not secure&amp;quot; warnings.">
    <meta property="og:description" content="... &amp;quot; ...">
    <meta name="twitter:description" content="... &amp;quot; ...">
    The entity is double-encoded (&amp;quot;) instead of &quot;.

Cause

KunenaParser::stripBBCode() returns HTML-encoded text when its $html argument is true (the default) — the UnHTMLEncode() step is gated behind if (!$html). The meta-building code passes that already-encoded string to setDescription() / setMetaData(), and the document layer applies htmlspecialchars() again when emitting the <meta> tag, producing the double encoding.

Fix

Pass $html = false at the four meta-description call sites so stripBBCode() returns plain text and the document encodes it exactly once. This matches how the codebase already builds plain-text page titles and tooltips (KunenaLayout, Topics JSON views already pass false).

Scope / risk

Two files, four one-token changes. No effect on visible post content — only <meta> description/OG/Twitter tags. Verified on a clean Kunena 7.0.6 install: double-encoded &amp;quot; count drops from 3 to 0; visible body unchanged.

A topic's meta description and Open Graph / Twitter card tags
double-encode HTML entities. A first post containing a double quote
renders as:

    <meta name="description" content="... &amp;quot;example&amp;quot; ...">

instead of the correct single-encoded `&quot;`. The visible post body is
unaffected; only the <meta name="description">, og:description and
twitter:description tags are wrong, which degrades search snippets and
social share previews.

Cause: KunenaParser::stripBBCode() returns HTML-encoded text when its
$html argument is true (the default) -- its UnHTMLEncode() step is gated
behind `if (!$html)`. The meta-building code passes that already-encoded
string to setDescription()/setMetaData(), and the document layer applies
htmlspecialchars() again when rendering the <meta> tag, producing the
double encoding.

Fix: pass $html = false at these meta-description call sites so
stripBBCode() returns plain text and the document encodes it exactly
once. This is consistent with how the codebase already builds plain-text
page titles and tooltips (KunenaLayout, Topics JSON views), which already
pass false.
@github-actions

Copy link
Copy Markdown

Thank you for the pr'' first pr

@xillibit xillibit added the 7.0 label Jun 20, 2026
@xillibit xillibit modified the milestones: 6.4, 7.0 Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants