Skip to content

fix(i18n): escape translated HTML outside an allowlist and reject markup changes in translations - #571

Merged
vitormattos merged 1 commit into
fix/translation-template-syntaxfrom
fix/escape-translated-html
Nov 14, 2026
Merged

vitormattos merged 1 commit into
fix/translation-template-syntaxfrom
fix/escape-translated-html

Conversation

@YvesCesar

Copy link
Copy Markdown
Member

Depends on #570 (based on its branch; the diff below is only this change).

Problem

  • source/faq.blade.php printed translated FAQ answers with {!! !!}, and post_base.blade.php printed the translated By %s format unescaped. Any HTML added in a translation was rendered as is on the localized pages.
  • Translated post bodies are Markdown and may carry HTML, but nothing checked that a translation keeps the markup of its source.

Changes

  • New TranslatedHtmlSanitizer escapes the FAQ answer and only restores <a href="https://...">, </a>, <strong> and <em>. The current answers use only an HTTPS link.
  • The author byline escapes the translated By %s format, the author name and the profile URL before building the link.
  • New TranslationMarkupValidator, run by composer validate-translations, fails when the set of HTML tags and attribute names of a translation differs from its source.

Validation

  • composer test: 98 tests passing, including the sanitizer and markup validator tests.
  • composer validate-translations passes on the current catalogs.
  • Local build in an isolated container: compared with fix(i18n): treat translated post bodies as text instead of templates #570, the only output changes are quotes in two FAQ answers now encoded as entities (&quot;, &#039;); the author byline is unchanged.
  • With a catalog adding HTML to an FAQ answer, to By %s and to a post body, the FAQ and byline render it escaped and composer validate-translations reports the three entries.

…kup changes in translations

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@vitormattos
vitormattos merged commit 79422eb into fix/translation-template-syntax Nov 14, 2026
5 checks passed
@vitormattos
vitormattos deleted the fix/escape-translated-html branch November 14, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants