Repository navigation
fix(i18n): treat translated post bodies as text instead of templates - #570
Merged
Merged
Conversation
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
…kup changes in translations Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Contributor
|
fix(i18n): escape translated HTML outside an allowlist and reject markup changes in translations
vitormattos
approved these changes
Nov 14, 2026
Contributor
|
🚀 Starting production deploy of site header and footer fragments... |
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.
Problem
TranslateContentHandlerreplaces each post body with the catalog translation and writes it back before Jigsaw renders the file. Jigsaw then compiles the file through Blade..blade.mdposts (envelopes,signature-order) Jigsaw only neutralizes<?php, so Blade echoes, raw echoes and directives coming from a translation were executed during the build..mdposts Jigsaw escapes@,{{and{!!, but not<?=,{@directiveor Blade component tags (<x-...>with bound attributes). Those were also evaluated during the build for any of the posts.lang/*/main.jsonfrom Hosted Weblate, so catalog text must be treated as data, not as template code.composer validate-translationsonly comparedprintfplaceholders, and indeploy.ymlthe catalogs were not validated beforecomposer prod.Changes
TranslateContentHandlerneutralizes template syntax in the translated body before writing it:<?and<x-/<x:become<,{@becomes{@, and in.blade.mdposts the same escape map Jigsaw applies to plain Markdown (@,{{,{!!) is applied, keeping only{{ $page->baseUrl }}.TranslationTemplateSyntaxValidator, run bycomposer validate-translations, rejects translations containing PHP tags, Blade component tags, raw echoes, echoes other than{{ $page->baseUrl }}, Blade directives not present in the source, or a different number of base URL echoes.deploy.ymlrunscomposer validate-translationsbeforecomposer prod.Validation
composer test: 87 tests passing. The newTranslateContentHandlerTestcases (Blade echo, raw echo,@php,<?=,{@php, component tag) fail onmainand pass with this change.composer validate-translationspasses on the current catalogs.npm run build-assets) in an isolated container without network, frommainand from this branch: the generatedbuild_localis identical apart from sitemap timestamps, and base URL images in the Blade posts still resolve.mainevaluated it; on this branch the build renders it as text, nothing is evaluated, andcomposer validate-translationsreports each entry.