StringUtils.parseLocaleString accepts Java 7 variants

Issue: SPR-14718
This commit is contained in:
Juergen Hoeller 2016-09-15 14:31:05 +02:00
parent 6de4b12992
commit f24ce76edb
2 changed files with 6 additions and 1 deletions

View File

@ -715,7 +715,7 @@ public abstract class StringUtils {
private static void validateLocalePart(String localePart) {
for (int i = 0; i < localePart.length(); i++) {
char ch = localePart.charAt(i);
if (ch != '_' && ch != ' ' && !Character.isLetterOrDigit(ch)) {
if (ch != ' ' && ch != '_' && ch != '#' && !Character.isLetterOrDigit(ch)) {
throw new IllegalArgumentException(
"Locale part \"" + localePart + "\" contains invalid characters");
}

View File

@ -692,4 +692,9 @@ public class StringUtilsTests {
assertEquals("Variant containing country code not extracted correctly", variant, locale.getVariant());
}
@Test // SPR-14718
public void testParseJava7Variant() {
assertEquals("sr_#LATN", StringUtils.parseLocaleString("sr_#LATN").toString());
}
}