mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Fix potential offset errors in BasicJsonParser
Update BasicJsonParser to fix potential exceptions if strings happen to be empty. Fixes gh-6136
This commit is contained in:
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…
Reference in New Issue
Block a user