Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,22 @@ public static String getSubstring(String value, int startIndex, int stopIndex, b
}

int len = value.length();
if (startIndex < 0 || stopIndex > len || startIndex >= stopIndex) {
if (startIndex >= stopIndex || len < stopIndex) {
return null;
}

int from = reverse ? len - stopIndex : startIndex;
int to = reverse ? len - startIndex : stopIndex;
for (int i = from; i < to; i++) {
for (int i = 0; i < len; i++) {
if (value.charAt(i) > 127) {
return null;
}
}

return value.substring(from, to);
if (reverse) {
int revStart = len - stopIndex;
int revStop = len - startIndex;
return value.substring(revStart, revStop);
} else {
return value.substring(startIndex, stopIndex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ use smithy.rules#endpointTests
"documentation": "unicode characters always return `None`",
"params": {
"TestCaseId": "1",
"Input": "\uD83D\uDC31abcdef"
"Input": "abcdef\uD83D\uDC31"
},
"expect": {
"error": "No tests matched"
Expand All @@ -168,7 +168,7 @@ use smithy.rules#endpointTests
"documentation": "non-ascii cause substring to always return `None`",
"params": {
"TestCaseId": "1",
"Input": "ab\u0080cdef"
"Input": "abcdef\u0080"
},
"expect": {
"error": "No tests matched"
Expand Down
Loading