Skip to content

Commit

Permalink
[FM] Properly sanitise the relative paths
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
  • Loading branch information
MuntashirAkon committed Aug 25, 2023
1 parent 34488a9 commit 0df32f8
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ private void goToRawPath(@NonNull String p) {
}
// Relative path
String goodPath = Paths.sanitize(p, false);
if (goodPath == null) {
if (goodPath == null || goodPath.equals(File.separator)) {
// No relative path means current path which is already loaded
return;
}
Expand All @@ -604,7 +604,7 @@ private void goToRawPath(@NonNull String p) {
List<String> pathSegments = currentUri.getPathSegments();
if (pathSegments.size() == 4) {
// For a tree URI, the 3rd index is the path
String lastPathSegment = pathSegments.get(3) + File.separator + p;
String lastPathSegment = pathSegments.get(3) + File.separator + goodPath;
Uri.Builder b = new Uri.Builder()
.scheme(currentUri.getScheme())
.authority(currentUri.getAuthority())
Expand All @@ -619,7 +619,7 @@ private void goToRawPath(@NonNull String p) {
}
// For others, simply append path segments at the end
@SuppressWarnings("SuspiciousRegexArgument") // We aren't on Windows
String[] segments = p.split(File.separator);
String[] segments = goodPath.split(File.separator);
Uri.Builder b = currentUri.buildUpon();
for (String segment : segments) {
b.appendPath(segment);
Expand Down

0 comments on commit 0df32f8

Please sign in to comment.