GLM-5.3 Flash · Balanced

add-html-sanitizer-for-translated-message-resources-keycloak

Keycloak · Java · M · 100–299 lines · 6 files

The normal review, with one generalist agent. Judge: Claude Opus 5.5.

Gold bugs found
2 of 7
Comments published
4
Comments matching a bug
2
Comments not matching
2
Cost of this PR
$0.150

Published comments (4)

mediumbugjs/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties:188

Revert message to i18next interpolation syntax broken for account console — i18next in `setUserProfileServerError` cannot substitute `{0}` or evaluate `{2,choice,...}`, so English users see the raw pattern instead of attribute names and counts. Restore `{{0}}`-style placeholders as community translations keep them; choice pluralization only works in server-rendered MessageFormat themes.

mediumbugjs/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties:3138

Java MessageFormat syntax rendered literally in admin console message — English admins see the raw MessageFormat syntax instead of attribute names and counts because the admin console interpolates this key via i18next in `setUserProfileServerError`. Restore `{{0}}`-style placeholders; the `{2,choice,...}` pluralization only works in server-rendered themes.

mediumbugmisc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java:150-161

`santizeAnchors` pairs anchor tags by order, rejecting reordered translations — A valid translation that reorders anchor tags fails the build with `Didn't find anchor tag` because `englishMatcher.find()` only advances on exact positional matches, and `replaceFirst()` also strips the first occurrence rather than the matched one. Collect the tags into sets and compare membership and counts instead.

mediumbugthemes/src/main/resources-community/theme/base/account/messages/messages_lt.properties:101

Lithuanian totpStep1 contains Italian text instead of Lithuanian — Lithuanian users see Italian on the OTP setup page; the same Italian also replaced `loginTotpStep1` in the login theme's messages_lt.properties. Replace both with a Lithuanian rendering of the new English wording; anchors are no longer needed since the source dropped them. **Also found in:** - `themes/src/main/resources-community/theme/base/login/messages/messages_lt.properties:71-71`

Gold bugs found (2)

mediumThe Lithuanian TOTP setup step was replaced with Italian text in both the account and login bundles.
mediumThe account and admin UI bundles now use Java MessageFormat placeholders and choice syntax for error-invalid-multivalued-size, but i18next expects {{n}}, so the UI shows literal {0}/{1}/{2} and the raw choice text.

Gold bugs missed (5)

mediumThe diff-trimming code computes common prefix and suffix independently, so they can overlap and substring throws StringIndexOutOfBoundsException, crashing the verifier instead of reporting the illegal HTML.
highnormalizeValue blanks the entire choice expression for some keys before HTML validation, so markup placed inside a choice branch of those keys bypasses the new verifier.
mediumThe anchor regex </?a[^>]*> in the theme verifier treats any tag starting with 'a' (<abbr>, <area>, ...) as an anchor tag, which can produce misleading anchor errors or strip such tags before HTML sanitizing.
mediumThe illegalHtmlTag fixture uses a malformed '</div' closing tag, so the sanitizer flags it for malformation and verifyIllegalHtmlTagDetected would still pass if <div> were permitted by POLICY_SOME_HTML; the test does not isolate the forbidden-tag check.
mediumsantizeAnchors removes matching opening anchor tags without checking that the translation keeps the matching closing </a> (or the same number of anchors), so a translation with an unclosed <a ...> passes verification and renders a link that swallows the following content.