Skip to content

WW-5549 validate locale parameters against supportedLocale#1602

Open
lukaszlenart wants to merge 1 commit intorelease/struts-6-8-xfrom
fix/WW-5549-i18n-supported-locale-s6
Open

WW-5549 validate locale parameters against supportedLocale#1602
lukaszlenart wants to merge 1 commit intorelease/struts-6-8-xfrom
fix/WW-5549-i18n-supported-locale-s6

Conversation

@lukaszlenart
Copy link
Member

Summary

  • Port of PR WW-5549 Fix I18nInterceptor supportedLocale breaking request_locale #1594 bug fix to Struts 6.x (bug fix only, no refactoring)
  • When supportedLocale is configured on I18nInterceptor, request_locale/request_cookie_locale parameters were ignored because AcceptLanguageLocaleHandler.find() matched the Accept-Language header before session/cookie handlers checked their explicit locale parameters
  • Stored locales (session/cookie) were never validated against supportedLocale, allowing stale locales to persist after configuration changes

Changes

  • Add isLocaleSupported() helper method to validate locales against supportedLocale configuration
  • RequestLocaleHandler.find() — validate request_only_locale against supportedLocale
  • AcceptLanguageLocaleHandler.find() — check request_only_locale FIRST, then fall back to Accept-Language matching
  • SessionLocaleHandler.find() — check request_locale BEFORE super.find() with supportedLocale validation
  • SessionLocaleHandler.read() — discard stale session locales not in supportedLocale
  • CookieLocaleHandler.find() — check request_cookie_locale BEFORE super.find() with supportedLocale validation
  • CookieLocaleHandler.read() — discard stale cookie locales not in supportedLocale

Test plan

  • All 20 existing I18nInterceptorTest tests pass
  • 4 new tests added and passing:
    • testRequestLocaleWithSupportedLocale — supported locale accepted
    • testUnsupportedRequestLocaleRejected — unsupported locale rejected
    • testStaleSessionLocaleRejected — stale session locale discarded
    • testCookieRequestLocaleWithSupportedLocale — cookie storage with supported locale works
  • Full core module build

🤖 Generated with Claude Code

When supportedLocale is configured on I18nInterceptor, request_locale
and request_cookie_locale parameters were ignored because
AcceptLanguageLocaleHandler.find() matched the Accept-Language header
before session/cookie handlers checked their explicit locale parameters.
Additionally, stored locales (session/cookie) were never validated
against supportedLocale.

Changes:
- Add isLocaleSupported() helper to validate locales against config
- RequestLocaleHandler.find() now validates against supportedLocale
- AcceptLanguageLocaleHandler.find() checks request_only_locale first,
  then falls back to Accept-Language matching
- SessionLocaleHandler.find() checks request_locale before super.find()
- CookieLocaleHandler.find() checks request_cookie_locale before
  super.find()
- SessionLocaleHandler.read() discards stale session locales
- CookieLocaleHandler.read() discards stale cookie locales

Port of PR #1594 (bug fix only, no refactoring)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
22 Security Hotspots
42.4% Coverage on New Code (required ≥ 80%)
3.4% Duplication on New Code (required ≤ 3%)
E Reliability Rating on New Code (required ≥ A)
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@lukaszlenart lukaszlenart changed the title fix(i18n): WW-5549 validate locale parameters against supportedLocale WW-5549 validate locale parameters against supportedLocale Feb 27, 2026
@lukaszlenart lukaszlenart marked this pull request as ready for review February 27, 2026 12:27
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