WW-5549 Fix I18nInterceptor supportedLocale breaking request_locale#1594
Open
lukaszlenart wants to merge 1 commit intomainfrom
Open
WW-5549 Fix I18nInterceptor supportedLocale breaking request_locale#1594lukaszlenart wants to merge 1 commit intomainfrom
lukaszlenart wants to merge 1 commit intomainfrom
Conversation
…e when supportedLocale is configured When supportedLocale was configured on the I18nInterceptor, the Accept-Language header match in AcceptLanguageLocaleHandler.find() returned early before SessionLocaleHandler/CookieLocaleHandler ever checked their explicit locale parameters (request_locale, request_cookie_locale). This made it impossible to switch locale via request parameters when supportedLocale was set. Changes: - Reorder AcceptLanguageLocaleHandler.find() to check request_only_locale before Accept-Language matching - Reorder SessionLocaleHandler.find() to check request_locale before super - Reorder CookieLocaleHandler.find() to check request_cookie_locale before super - Add isLocaleSupported() helper to validate locales against supportedLocale - Filter all locale sources (params, session, cookies) through supportedLocale - Add 4 tests covering the bug scenario and supportedLocale filtering 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
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
Fixes WW-5549
request_locale/request_cookie_localeparameters being ignored whensupportedLocaleis configured on the I18nInterceptorsupportedLocaleas a global filter on all locale sources (request params, session, cookies)supportedLocaleconfiguration changesProblem
When
supportedLocalewas configured,AcceptLanguageLocaleHandler.find()matched the Accept-Language header beforeSessionLocaleHandler/CookieLocaleHandlercould check their explicit locale parameters (request_locale,request_cookie_locale). This made it impossible to switch locale via request parameters.Additionally,
supportedLocalewas only applied to Accept-Language matching — locales from request params, session storage, and cookies were never validated against it.Changes
request_locale,request_cookie_locale) are now checked before Accept-Language fallbackisLocaleSupported()helper: validates a locale against thesupportedLocaleset (no-op when empty, preserving backward compatibility)supportedLocaleTest plan
I18nInterceptorTestpass (14 existing + 4 new)request_localeworks withsupportedLocaleconfigured (SESSION storage)request_localeis rejected and falls backsupportedLocalechangesrequest_cookie_localeworks withsupportedLocale(COOKIE storage)supportedLocaleis not configured🤖 Generated with Claude Code