[ https://issues.apache.org/jira/browse/WW-5422?focusedWorklogId=918902&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-918902 ]
ASF GitHub Bot logged work on WW-5422: -------------------------------------- Author: ASF GitHub Bot Created on: 11/May/24 06:05 Start Date: 11/May/24 06:05 Worklog Time Spent: 10m Work Description: sonarcloud[bot] commented on PR #931: URL: https://github.com/apache/struts/pull/931#issuecomment-2105584154 ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=931) **Quality Gate failed** Failed conditions ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [66.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=931&metric=new_coverage&view=list) (required ≥ 80%) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [8.5% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=931&metric=new_duplicated_lines_density&view=list) (required ≤ 3%) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=931) Issue Time Tracking ------------------- Worklog Id: (was: 918902) Time Spent: 0.5h (was: 20m) > I18nInterceptor and invalid locale > ---------------------------------- > > Key: WW-5422 > URL: https://issues.apache.org/jira/browse/WW-5422 > Project: Struts 2 > Issue Type: Bug > Components: Core Interceptors > Affects Versions: 6.3.0 > Reporter: Andreas Sachs > Assignee: Lukasz Lenart > Priority: Minor > Fix For: 6.5.0 > > Time Spent: 0.5h > Remaining Estimate: 0h > > Exception if locale contains trimable characters: > > Eg Request: > request_locale=de%0A > > Code from I18nInterceptor line 187: > > {code:java} > if (localeProvider.isValidLocaleString(localeStr)) { > locale = LocaleUtils.toLocale(localeStr); > }{code} > > isValidLocaleString returns true because localeStr is trimmed inside function > ( > locale = LocaleUtils.toLocale(StringUtils.trimToNull(localeStr)) ) > > but LocaleUtils.toLocale(localeStr) will throw an exception afterwards. > > > > {code:java} > > java.lang.IllegalArgumentException: Invalid locale format: de > at > org.apache.commons.lang3.LocaleUtils.parseLocale(LocaleUtils.java:268) > ~[org.apache.commons-commons-lang3-3.12.0-.jar:3.12.0] > at > org.apache.commons.lang3.LocaleUtils.toLocale(LocaleUtils.java:348) > ~[org.apache.commons-commons-lang3-3.12.0-.jar:3.12.0] > at > org.apache.struts2.interceptor.I18nInterceptor.getLocaleFromParam(I18nInterceptor.java:188) > ~[org.apache.struts-struts2-core-6.3.0.2-.jar:6.3.0.2] > at > org.apache.struts2.interceptor.I18nInterceptor$SessionLocaleHandler.find(I18nInterceptor.java:321) > ~[org.apache.struts-struts2-core-6.3.0.2-.jar:6.3.0.2] > {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)