Skip to content

Commit f94eff0

Browse files
committed
<fix>[core]: handle malformed Accept-Language header in LocaleUtils
Java's String.split(";") on ";;;" returns an empty array, causing ArrayIndexOutOfBoundsException in parseAcceptLanguage. Add bounds check before accessing tagAndParams[0]. Change-Id: I$(openssl rand -hex 20)
1 parent 708fc5e commit f94eff0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

core/src/main/java/org/zstack/core/errorcode/LocaleUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ private static List<LocaleEntry> parseAcceptLanguage(String header) {
8888
continue;
8989
}
9090
String[] tagAndParams = part.split(";");
91+
if (tagAndParams.length == 0) {
92+
continue;
93+
}
9194
String tag = tagAndParams[0].trim();
95+
if (tag.isEmpty()) {
96+
continue;
97+
}
9298
double quality = 1.0;
9399
for (int i = 1; i < tagAndParams.length; i++) {
94100
String param = tagAndParams[i].trim();

0 commit comments

Comments
 (0)