Fix potential offset errors in BasicJsonParser

Update BasicJsonParser to fix potential exceptions if strings happen
to be empty.

Fixes gh-6136
pull/6184/head
Ivan Sopov 9 years ago committed by Phillip Webb
parent ed6f11d60d
commit 1528764194

@ -93,14 +93,14 @@ public class BasicJsonParser implements JsonParser {
}
private static String trimTrailingCharacter(String string, char c) {
if (string.length() >= 0 && string.charAt(string.length() - 1) == c) {
if (string.length() > 0 && string.charAt(string.length() - 1) == c) {
return string.substring(0, string.length() - 1);
}
return string;
}
private static String trimLeadingCharacter(String string, char c) {
if (string.length() >= 0 && string.charAt(0) == c) {
if (string.length() > 0 && string.charAt(0) == c) {
return string.substring(1);
}
return string;

Loading…
Cancel
Save