Skip to content

fix(i18n): treat translated post bodies as text instead of templates - #570

Merged
vitormattos merged 3 commits into
mainfrom
fix/translation-template-syntax
Nov 14, 2026
Merged

vitormattos merged 3 commits into
mainfrom
fix/translation-template-syntax

Conversation

@YvesCesar

Copy link
Copy Markdown
Member

Problem

  • TranslateContentHandler replaces each post body with the catalog translation and writes it back before Jigsaw renders the file. Jigsaw then compiles the file through Blade.
  • For .blade.md posts (envelopes, signature-order) Jigsaw only neutralizes <?php, so Blade echoes, raw echoes and directives coming from a translation were executed during the build.
  • For plain .md posts Jigsaw escapes @, {{ and {!!, but not <?=, {@directive or Blade component tags (<x-...> with bound attributes). Those were also evaluated during the build for any of the posts.
  • Translations reach lang/*/main.json from Hosted Weblate, so catalog text must be treated as data, not as template code.
  • composer validate-translations only compared printf placeholders, and in deploy.yml the catalogs were not validated before composer prod.

Changes

  • TranslateContentHandler neutralizes template syntax in the translated body before writing it: <? and <x-/<x: become &lt;, {@ becomes {&#64;, and in .blade.md posts the same escape map Jigsaw applies to plain Markdown (@, {{, {!!) is applied, keeping only {{ $page->baseUrl }}.
  • New TranslationTemplateSyntaxValidator, run by composer 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.yml runs composer validate-translations before composer prod.

Validation

  • composer test: 87 tests passing. The new TranslateContentHandlerTest cases (Blade echo, raw echo, @php, <?=, {@php, component tag) fail on main and pass with this change.
  • composer validate-translations passes on the current catalogs.
  • Built the site locally (npm run build-assets) in an isolated container without network, from main and from this branch: the generated build_local is identical apart from sitemap timestamps, and base URL images in the Blade posts still resolve.
  • With a catalog containing the syntax above in a Blade post and in a plain Markdown post, the build on main evaluated it; on this branch the build renders it as text, nothing is evaluated, and composer validate-translations reports each entry.

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
…kup changes in translations

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1-4-g2a6da11

QR code for preview link

🚀 View preview at
https://libresign.github.io/site-preview/pr-preview/pr-570/

Built to branch gh-pages at 2026-11-14 17:09 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

fix(i18n): escape translated HTML outside an allowlist and reject markup changes in translations
@vitormattos
vitormattos merged commit ee8eae5 into main Nov 14, 2026
7 checks passed
@vitormattos
vitormattos deleted the fix/translation-template-syntax branch November 14, 2026 17:09
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Starting production deploy of site header and footer fragments...

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