mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Fixed MimeUtility.getHeaderParameter() to not crash on unexpected input
This commit is contained in:
parent
561d2a1a44
commit
aeb0220e56
@ -953,19 +953,23 @@ public class MimeUtility {
|
||||
}
|
||||
header = header.replaceAll("\r|\n", "");
|
||||
String[] parts = header.split(";");
|
||||
if (name == null) {
|
||||
if (name == null && parts.length > 0) {
|
||||
return parts[0];
|
||||
}
|
||||
for (String part : parts) {
|
||||
if (part.trim().toLowerCase(Locale.US).startsWith(name.toLowerCase(Locale.US))) {
|
||||
String parameter = part.split("=", 2)[1].trim();
|
||||
if (parameter.startsWith("\"") && parameter.endsWith("\"")) {
|
||||
return parameter.substring(1, parameter.length() - 1);
|
||||
String[] partParts = part.split("=", 2);
|
||||
if (partParts.length == 2) {
|
||||
String parameter = partParts[1].trim();
|
||||
int len = parameter.length();
|
||||
if (len >= 2 && parameter.startsWith("\"") && parameter.endsWith("\"")) {
|
||||
return parameter.substring(1, len - 1);
|
||||
} else {
|
||||
return parameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user