Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringUtils.parseLocaleString: locale variant cannot contain country code [SPR-11806] #16426

Closed
spring-projects-issues opened this issue May 19, 2014 · 1 comment
Assignees
Labels
in: core status: backported type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 19, 2014

John Olmstead opened SPR-11806 and commented

The StringUtils.parseLocaleString method fails to correctly parse the variant if the variant contains the same characters as the country code. This is due to the fact that the lastIndexOf the country code is used as the dividing point instead of the first indexOf.

Here is the test to add to org.springframework.util.StringUtilsTest:

public void testParseLocaleWithVarientContainingCountryCode() throws Exception {
    final String variant = "GBtest";
    final String localeString = "en_GB_" + variant;
    Locale locale = StringUtils.parseLocaleString(localeString);
    assertEquals("Variant containing country code not extracted correctly.", variant, locale.getVariant());
}

Affects: 3.2.8, 4.0.4

Backported to: 3.2.9

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 19, 2014

Juergen Hoeller commented

Reported just in time for 4.0.5 & 3.2.9... Fixed in master now, to be available in the upcoming 4.0.5 & 3.2.9 snapshots in about an hour.

Juergen

@spring-projects-issues spring-projects-issues added type: bug status: backported in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.0.5 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: backported type: bug
Projects
None yet
Development

No branches or pull requests

2 participants