Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: #3767 StringIndexOutOfBoundsException on HybridFile#getParent #3971

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

seelchen
Copy link
Contributor

@seelchen seelchen commented Oct 25, 2023

Description

Fix StringIndexOutOfBoundsException by checking if the end index given to the substring() function is negative. This can happen if the currentName does not occur in thisPath which causes the lastIndexOf() function to return -1.

Issue tracker

Fixes #3767

Automatic tests

  • Added test cases

Manual tests

  • Done

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

@seelchen
Copy link
Contributor Author

This PR "fixes" the bug in a way that the StringIndexOutOfBoundsException won't be thrown but instead null is returned.
However, this probably does not address the root cause of the bug, which is that in some edge case the last element of pathSegments cannot be found in thisPath. Since the elements in pathSegments are constructed using thisPath, all of them should be contained in thisPath.
My guess is that maybe the elements in pathSegments are decoded (see documentation of getPathSegments()) and thisPath is still encoded, but I was not successful in finding a URI which could confirm my guess (I tried e.g. spaces vs +, but + was not decoded in thisPath nor pathSegments).

@seelchen seelchen marked this pull request as ready for review October 26, 2023 21:27
@VishalNehra VishalNehra merged commit 337b78b into TeamAmaze:release/4.0 Oct 30, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StringIndexOutOfBoundsException on HybridFile#getParent
2 participants