WW-5549 validate locale parameters against supportedLocale#1602
Open
lukaszlenart wants to merge 1 commit intorelease/struts-6-8-xfrom
Open
WW-5549 validate locale parameters against supportedLocale#1602lukaszlenart wants to merge 1 commit intorelease/struts-6-8-xfrom
lukaszlenart wants to merge 1 commit intorelease/struts-6-8-xfrom
Conversation
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>
core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java
Dismissed
Show dismissed
Hide dismissed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
supportedLocaleis configured onI18nInterceptor,request_locale/request_cookie_localeparameters were ignored becauseAcceptLanguageLocaleHandler.find()matched the Accept-Language header before session/cookie handlers checked their explicit locale parameterssupportedLocale, allowing stale locales to persist after configuration changesChanges
isLocaleSupported()helper method to validate locales againstsupportedLocaleconfigurationRequestLocaleHandler.find()— validaterequest_only_localeagainstsupportedLocaleAcceptLanguageLocaleHandler.find()— checkrequest_only_localeFIRST, then fall back to Accept-Language matchingSessionLocaleHandler.find()— checkrequest_localeBEFOREsuper.find()withsupportedLocalevalidationSessionLocaleHandler.read()— discard stale session locales not insupportedLocaleCookieLocaleHandler.find()— checkrequest_cookie_localeBEFOREsuper.find()withsupportedLocalevalidationCookieLocaleHandler.read()— discard stale cookie locales not insupportedLocaleTest plan
I18nInterceptorTesttests passtestRequestLocaleWithSupportedLocale— supported locale acceptedtestUnsupportedRequestLocaleRejected— unsupported locale rejectedtestStaleSessionLocaleRejected— stale session locale discardedtestCookieRequestLocaleWithSupportedLocale— cookie storage with supported locale works🤖 Generated with Claude Code