[K7.0] Fix double-encoded entities in topic meta description tags#10123
Open
genr8r wants to merge 1 commit into
Open
[K7.0] Fix double-encoded entities in topic meta description tags#10123genr8r wants to merge 1 commit into
genr8r wants to merge 1 commit into
Conversation
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="... &quot;example&quot; ...">
instead of the correct single-encoded `"`. 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.
|
Thank you for the pr'' first pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Sites can show "not secure" warnings.&quot;) instead of".Cause
KunenaParser::stripBBCode()returns HTML-encoded text when its$htmlargument istrue(the default) — theUnHTMLEncode()step is gated behindif (!$html). The meta-building code passes that already-encoded string tosetDescription()/setMetaData(), and the document layer applieshtmlspecialchars()again when emitting the<meta>tag, producing the double encoding.Fix
Pass
$html = falseat the four meta-description call sites sostripBBCode()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 passfalse).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&quot;count drops from 3 to 0; visible body unchanged.