Skip to content

Commit

Permalink
Merge pull request TeamAmaze#3971 from seelchen/bugfix/3767
Browse files Browse the repository at this point in the history
Bug fix: TeamAmaze#3767 `StringIndexOutOfBoundsException` on `HybridFile#getParent`
  • Loading branch information
VishalNehra authored Oct 30, 2023
2 parents 253ef47 + 8386743 commit 337b78b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,11 @@ public String getParent(Context context) {
if (thisPath.isEmpty() || pathSegments.isEmpty()) return null;

String currentName = pathSegments.get(pathSegments.size() - 1);
String parent = thisPath.substring(0, thisPath.lastIndexOf(currentName));
int currentNameStartIndex = thisPath.lastIndexOf(currentName);
if (currentNameStartIndex < 0) {
return null;
}
String parent = thisPath.substring(0, currentNameStartIndex);
if (ArraysKt.any(ANDROID_DATA_DIRS, dir -> parent.endsWith(dir + "/"))) {
return FileProperties.unmapPathForApi30OrAbove(parent);
} else {
Expand Down

0 comments on commit 337b78b

Please sign in to comment.