Skip to content

fix(l10n): evaluate the plural header without the Function constructor - #9983

Merged
rubenvdlinde merged 2 commits into
mainfrom
fix/l10n-plural-without-eval
Nov 12, 2026
Merged

rubenvdlinde merged 2 commits into
mainfrom
fix/l10n-plural-without-eval

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

scripts/l10n/runtime-check.mjs compiled the plural= expression from a locale bundle's header with new Function, which is dynamic code execution. It now goes through scripts/l10n/pluralExpression.js, a small parser for the C subset that gettext plural headers use: integers, n, parentheses, ! * / % + -, comparisons, && || and ? :. Anything else throws a SyntaxError, and the check reports that as a failed assertion, the same way a parse error was reported before.

Criterion result (fork checker, owaspsecurecoding)

Run with the fork's own checkOwaspSecureCoding against main and against this branch.

main this branch
Fork as deployed now warn, 13 findings warn, 12 findings
Fork with rubenvdlinde/CommonGroundChecker#2 warn, 1 finding pass, 0 findings

This was the one real hit of the 13. The other 12 are false positives in the checker's heuristic, not in this code:

  • eval() named in a comment (MetricExpressionEvaluator, UnaryTestEvaluator, both of which exist so that nothing calls eval), and PyTorch's model.eval() method in docker/dolphin/api_server.py.
  • "Possible hardcoded secret" on values that are not secrets: config key names (portal_assertion_secret, openregister_case_token), a hash prefix, redaction placeholders ([redacted], [erased]), two regular expressions, a format to input-type map (password: 'password') and a bound Vue attribute (:token="createdToken").

The checker already leaves tests out of this scan, so these sit in production code. Renaming constants or rewording comments to dodge a regex would make the code worse. The fix belongs in the checker, and the fork PR above does that.

Verified locally

  • node scripts/l10n/runtime-check.mjs <loc> for nl, de, is, mk, pl and ar gives the same output as before (nl and ar were already failing on main, for reasons unrelated to plurals).
  • The parser agrees with new Function on every plural= expression in l10n/*.json (16 distinct), for n from 0 to 1000.
  • npx jest scripts/l10n/pluralExpression.spec.js: 13 passed.
  • eslint on the changed files: no new findings. runtime-check.mjs keeps 14 inherited jsdoc warnings on lines this PR does not touch.

AI assistance: prepared with Claude Code (Opus 5.5) and reviewed before submission.

The runtime check compiled the bundle's plural= expression with
new Function. A small parser for the C subset that plural headers use
now evaluates it, and rejects anything else.

Assisted-by: ClaudeCode:claude-opus-5-5
rubenvdlinde added a commit that referenced this pull request Nov 12, 2026
@rubenvdlinde
rubenvdlinde merged commit 8a55c3f into main Nov 12, 2026
16 of 24 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 011d301

Check PHP Vue Security License Tests
lint ✅
phpcs ❌
phpmd ❌
psalm ❌
phpstan ❌
phpmetrics ✅
eslint ❌
stylelint ✅
build ✅
check-specs ✅
test-l10n ❌
test-l10n-parity ❌
format ❌
check-schema-l10n ✅
test-newman-route-ratchet ✅
composer ✅ ✅ 169/169
npm ✅ ✅ 639/639
app:check-code ⏭️
info.xml ✅
REUSE ✅
lockfile sync ✅
PHPUnit ❌ 56561/56769 · 27 skipped (worst of 6 legs: PHP 8.3, NC stable32, pgsql; counts from 6 of 8 legs)
Newman ❌
Playwright ❌ 237/324 · 5 skipped · 164 did not run
Hydra gates ❌

Quality workflow — 2026-11-14 09:00 UTC

Download the full PDF report from the workflow artifacts.

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.

1 participant