DeepSeek V4 Pro · 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.606

Published comments (4)

mediumbugmisc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java:67-68

PropertyResourceBundle decodes UTF-8 message files as ISO-8859-1 — Non-Latin translations are read as mojibake, so `verifySafeHtml` operates on corrupted strings and its `Illegal HTML` output is garbled for those locales. Use `new PropertyResourceBundle(new InputStreamReader(fis, StandardCharsets.UTF_8))`, including the English bundle nearby.

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

santizeAnchors compares translation and English anchors by position — A translation that reorders two links is reported as `Didn't find anchor tag ... in original string` and fails the build even though the anchors are unchanged. Match each translation anchor against the set of English anchors rather than requiring identical order.

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

totpStep1 contains Italian text instead of Lithuanian — Lithuanian-locale users see Italian instructions in the OTP setup flow. Replace `totpStep1` with the correct Lithuanian translation of `Install one of the following applications on your mobile:`. **Also found in:** - `themes/src/main/resources-community/theme/base/login/messages/messages_lt.properties:71-71`

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

Use i18next {{n}} interpolation for error-invalid-multivalued-size — The single-brace placeholders and the Java `{2,choice,...}` pattern are not interpolated, so `error-invalid-multivalued-size` renders as literal `{0}`/`{2,choice,...}` text when shown via `setUserProfileServerError`. Revert to `{{0}} must have at least {{1}} and at most {{2}}` or use real i18next pluralization. **Also found in:** - `js/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties:188-188`

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.