-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Affected Method (full signature)
com.amaze.filemanager.filesystem.files.FileUtils.isCompressedFile(String path)
Environment
• App version: AmazeFileManager release/4.0 (unmodified source)
• Platform: Java 17 / JVM unit tests
⸻
Steps to Reproduce:
FileUtils.isCompressedFile(" /tmp/archive.rar "); // → false (BUG)
FileUtils.isCompressedFile("/tmp/a .zip"); // → false (BUG)
1. Call the method with leading, trailing, or inline spaces around the filename or extension.
2. The internal extension extraction runs before trimming, so the comparison string includes spaces.
⸻
Expected Behavior
Whitespace around filenames or extensions should be ignored.
All of the above inputs should return true because the base extension is .rar or .zip.
Actual Behavior
Returns false whenever whitespace is present before or after the dot segment.
⸻
Impact (Why it matters)
Users with filenames that contain stray spaces (common when renaming or copying) see valid compressed files mis-categorized.
This affects file-type filters, previews, and UI sorting in AmazeFileManager.
⸻
Suggested Fix (One paragraph, no code changes)
Before extracting and validating the extension, normalize input by trimming and collapsing internal whitespace:
path = path.trim(); and ensure the substring following the last . is trimmed before comparison.
This guarantees .rar, .zip, .7z, etc. are recognized regardless of spacing or casing.