Skip to content

Commit 1040b01

Browse files
authored
Merge pull request #4482 from siddhesh-06/siddhesh06/fix/whitespace-filename-issue
2 parents 410f8ac + d3069ec commit 1040b01

File tree

1 file changed

+14
-2
lines changed
  • app/src/main/java/com/amaze/filemanager/filesystem/files

1 file changed

+14
-2
lines changed

app/src/main/java/com/amaze/filemanager/filesystem/files/FileUtils.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,20 @@ public static boolean isRoot(
968968

969969
/** Convenience method to return if a path points to a compressed file. */
970970
public static boolean isCompressedFile(String path) {
971-
@Nullable String extension = MimeTypes.getExtension(path);
972-
return ArraysKt.indexOf(COMPRESSED_FILE_EXTENSIONS, extension) > -1;
971+
if (path == null) return false;
972+
973+
// Normalize input: trim leading/trailing whitespace first
974+
String normalizedPath = path.trim();
975+
if (normalizedPath.isEmpty()) return false;
976+
977+
// Extract extension using MimeTypes helper, then normalize it
978+
String extension = MimeTypes.getExtension(normalizedPath);
979+
if (!extension.isEmpty()) {
980+
extension = extension.trim().toLowerCase(Locale.getDefault());
981+
return ArraysKt.indexOf(COMPRESSED_FILE_EXTENSIONS, extension) > -1;
982+
}
983+
984+
return false;
973985
}
974986

975987
/** Converts ArrayList of HybridFileParcelable to ArrayList of File */

0 commit comments

Comments
 (0)