DeepSeek V4 Pro · Heavy

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

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

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.

Gold bugs found
2 of 7
Comments published
5
Comments matching a bug
2
Comments not matching
3
Cost of this PR
$1.998

Published comments (5)

mediumbugmisc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java:66-77

PropertyResourceBundle decodes UTF-8 properties as ISO-8859-1 — Every non-ASCII translation is decoded as mojibake before HTML comparison, so sanitize, containsHtml, santizeAnchors, and their diagnostics can misreport or garble results. Construct the bundles from a UTF-8 reader such as new PropertyResourceBundle(new InputStreamReader(fis, StandardCharsets.UTF_8)).

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

Use i18next {{...}} placeholders for multivalued-size error — The account console will render literal {0}, {1}, {2}, and {2,choice,...} text for multivalued-size errors. Keep the {{0}}/{{1}}/{{2}} syntax in the React bundles; the identical change in js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties breaks the admin console the same way.

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

Italian text overwrote Lithuanian totpStep1 and loginTotpStep1 translations — Lithuanian users are shown Italian instructions for totpStep1 and loginTotpStep1. Restore the Lithuanian translation for both keys in the account and login files. **Also found in:** - `themes/src/main/resources-community/theme/base/login/messages/messages_lt.properties:71-71`

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

Anchor validation compares tags positionally instead of by membership — Reordering identical anchors or using only the second of two source anchors compares against the wrong English anchor and reports a missing tag. Check membership of each translated anchor against the full set of English anchors instead of consuming englishMatcher positionally.

mediumbugthemes/src/main/resources-community/theme/base/account/messages/messages_zh_CN.properties:112

totpStep1 uses Traditional Chinese in Simplified Chinese locale — Users of the zh_CN locale see the wrong character variant. Replace totpStep1 with Simplified Chinese text such as '在您的手机上安装以下应用程序之一:'.

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.