[
https://issues.apache.org/jira/browse/WW-5549?focusedWorklogId=1006593&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1006593
]
ASF GitHub Bot logged work on WW-5549:
--------------------------------------
Author: ASF GitHub Bot
Created on: 22/Feb/26 17:04
Start Date: 22/Feb/26 17:04
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #1594:
URL: https://github.com/apache/struts/pull/1594
## Summary
Fixes [WW-5549](https://issues.apache.org/jira/browse/WW-5549)
- Fix `request_locale` / `request_cookie_locale` parameters being ignored
when `supportedLocale` is configured on the I18nInterceptor
- Apply `supportedLocale` as a global filter on all locale sources (request
params, session, cookies)
- Reject stale session/cookie locales when `supportedLocale` configuration
changes
## Problem
When `supportedLocale` was configured, `AcceptLanguageLocaleHandler.find()`
matched the Accept-Language header **before** `SessionLocaleHandler` /
`CookieLocaleHandler` could check their explicit locale parameters
(`request_locale`, `request_cookie_locale`). This made it impossible to switch
locale via request parameters.
Additionally, `supportedLocale` was only applied to Accept-Language matching
— locales from request params, session storage, and cookies were never
validated against it.
## Changes
- **Reorder locale resolution priority**: explicit request parameters
(`request_locale`, `request_cookie_locale`) are now checked **before**
Accept-Language fallback
- **Add `isLocaleSupported()` helper**: validates a locale against the
`supportedLocale` set (no-op when empty, preserving backward compatibility)
- **Filter all locale sources**: request params, session-stored locales, and
cookie-stored locales are all validated against `supportedLocale`
- **Add 4 test cases** covering the bug scenario and supportedLocale
filtering
## Test plan
- [x] All 18 tests in `I18nInterceptorTest` pass (14 existing + 4 new)
- [ ] Verify `request_locale` works with `supportedLocale` configured
(SESSION storage)
- [ ] Verify unsupported `request_locale` is rejected and falls back
- [ ] Verify stale session locale is rejected when `supportedLocale` changes
- [ ] Verify `request_cookie_locale` works with `supportedLocale` (COOKIE
storage)
- [ ] Full backward compatibility when `supportedLocale` is not configured
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 1006593)
Remaining Estimate: 0h
Time Spent: 10m
> i18n interceptor param supportedLocale (when set) disables request_locale
> param functionality
> ---------------------------------------------------------------------------------------------
>
> Key: WW-5549
> URL: https://issues.apache.org/jira/browse/WW-5549
> Project: Struts 2
> Issue Type: Bug
> Components: Core Interceptors
> Affects Versions: 6.3.0
> Reporter: Rafa
> Assignee: Lukasz Lenart
> Priority: Minor
> Fix For: 6.9.0, 7.2.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> It seems that when {{supportedLocale}} parameter is set on {{i18n}}
> interceptor - language change using {{request_locale}} param is not possible
> anymore if current browser {{Accept-Language}} matches the
> {{supportedLocale}} value.
> I set {{supportedLocale}} parameter on the {{i18n}} interceptor (e.g. to
> {{fr,en}} value). Now i enter the webapp (using a browser with fr language
> set as default) and the struts locale is set to {{fr}} (as expected - ok).
> Now i try switching the locale to {{en}} using the {{?request_locale=en}}
> built-in feature - but this does not work ({{{}fr{}}} is still set as
> language).
> If i do not set the {{supportedLocale}} param on the {{i18n}} interceptor -
> everything works fine (for exactly the same webapp, and the
> {{request_locale}} request param switch is working fine) but then i loose the
> feature of {_}struts preselecting fr language as default for browsers with fr
> language set as default{_}.
> When i look into the source code of
> [I18nInterceptor.java|https://github.com/apache/struts/blob/main/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java#L302]
> (line 302) it looks like {{AcceptLanguageLocaleHandler.find()}} (the
> {{super.find()}} from this line) is always returning one of the
> {{supportedLocale}} locales if browser has matching {{Accept-Language}}
> header (and {{supportedLocale}} value is set) - but it shall not e.g. when
> {{request_locale}} param is set (it shall take precedence here).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)