Skip to content

[isCompressedFile] Whitespace around filename or extension causes false negative #4478

@wassdak

Description

@wassdak

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.

Metadata

Metadata

Assignees

Labels

Area-FileOperationsRelated to file operations (e.g. moving, copying, renaming).Issue-BugRelated unexpected behavior or something worth investigating.Issue-Easy (good first issue)Beginners welcome! Issues with relative low difficulty.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions