AcceptHeaderLocaleResolver chooses wrong Locale for language match [SPR-16599] #21140
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Naozumi Taromaru opened SPR-16599 and commented
Order of Locale in Accept-Language Header is slighted in AcceptHeaderLocaleResolver.
For example:
supportedLocales of AcceptHeaderLocaleResolver: ja, en_US, en
Accept-Language of Request: ja-JP,en-US;q=0.5
Expected: ja
Actual: en_US
"ja-JP,en-US;q=0.5" is meaning as "ja-JP > ja > en-US > en".
(Reference: Last "For example" of https://tools.ietf.org/html/rfc4647#section-3.4.1)
And "ja" is supported.
So expected Locale is "ja".
Suggestion:
Change "languageMatch = candidate;"
at
https://github.com/spring-projects/spring-framework/blob/v5.0.4.RELEASE/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java#L132
to "return candidate;".
And delete languageMatch(always null).
Affects: 5.0.4
Reference URL: #21002
Issue Links:
Referenced from: commits 6e1cac9, f8588e3
Backported to: 4.3.15
The text was updated successfully, but these errors were encountered: