-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b124
-
Verified
LanguageRange.parse() method fails in locales such as Turkish. Reason is that the parse() method uses toLowerCase() method which when used the in locales like Turkish returns the range string containing characters which are not acceptable in the language-range.
e.g.
"HI-Deva".toLowerCase() in a Turkish locale returns "hı-deva", where 'ı' is the LATIN SMALL LETTER DOTLESS I character which is not a valid language-range character.
Below code snippet can be used to reproduce the issue
/*
String ranges = "HI-Deva";
String tags = "en, hi-deva";
FilteringMode mode = EXTENDED_FILTERING;
Locale.setDefault(new Locale("tr","TR")); //setting the turkish locale
List<LanguageRange> priorityList = LanguageRange.parse(ranges); // throws IllegalArgumentException
*/
It throws exception as:
Exception in thread "main" java.lang.IllegalArgumentException: range=hı-deva
at java.util.Locale$LanguageRange.<init>(java.base@9-internal/Locale.java:2908)
at sun.util.locale.LocaleMatcher.parse(java.base@9-internal/LocaleMatcher.java:285)
Expectation:
range.toLowerCase() should work on the ROOT locale irrespective of other locales
Actual:
range.toLowerCase() is working as range.toLowerCase(Locale.getDefault()) which fails in locales like turkish
e.g.
"HI-Deva".toLowerCase() in a Turkish locale returns "hı-deva", where 'ı' is the LATIN SMALL LETTER DOTLESS I character which is not a valid language-range character.
Below code snippet can be used to reproduce the issue
/*
String ranges = "HI-Deva";
String tags = "en, hi-deva";
FilteringMode mode = EXTENDED_FILTERING;
Locale.setDefault(new Locale("tr","TR")); //setting the turkish locale
List<LanguageRange> priorityList = LanguageRange.parse(ranges); // throws IllegalArgumentException
*/
It throws exception as:
Exception in thread "main" java.lang.IllegalArgumentException: range=hı-deva
at java.util.Locale$LanguageRange.<init>(java.base@9-internal/Locale.java:2908)
at sun.util.locale.LocaleMatcher.parse(java.base@9-internal/LocaleMatcher.java:285)
Expectation:
range.toLowerCase() should work on the ROOT locale irrespective of other locales
Actual:
range.toLowerCase() is working as range.toLowerCase(Locale.getDefault()) which fails in locales like turkish