-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[getPathsInPath] Plain/whitespace path without scheme triggers splitUri NPE #4476
Copy link
Copy link
Open
Labels
Area-FileOperationsRelated to file operations (e.g. moving, copying, renaming).Related to file operations (e.g. moving, copying, renaming).Issue-BugRelated unexpected behavior or something worth investigating.Related unexpected behavior or something worth investigating.Issue-Easy (good first issue)Beginners welcome! Issues with relative low difficulty.Beginners welcome! Issues with relative low difficulty.
Metadata
Metadata
Assignees
Labels
Area-FileOperationsRelated to file operations (e.g. moving, copying, renaming).Related to file operations (e.g. moving, copying, renaming).Issue-BugRelated unexpected behavior or something worth investigating.Related unexpected behavior or something worth investigating.Issue-Easy (good first issue)Beginners welcome! Issues with relative low difficulty.Beginners welcome! Issues with relative low difficulty.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Affected Method (full signature):
com.amaze.filemanager.filesystem.files.FileUtils.getPathsInPath(String path)
Environment:
• AmazeFileManager: stock release/4.0 (no local edits)
• Java 17 (JVM unit tests)
Steps to Reproduce (pure Java):
1. Call getPathsInPath("/") or getPathsInPath(" /dir/ ").
2. Method trims and attempts URI split on a non-URI (plain path).
3. Null handling inside splitUri causes a NullPointerException.
Expected Behavior:
Plain filesystem paths should be handled without trying to parse URI schemes; the method should return incremental components or an empty array.
Actual Behavior:
NullPointerException inside splitUri when path has no scheme (e.g., /, /dir/, or whitespace-padded).
Minimal Input Example:
String[] parts = FileUtils.getPathsInPath("/");
Impact (why it matters):
Crashes on common inputs (root, trimmed paths) break navigation and any feature that enumerates path segments.
Suggested Fix (no code, one paragraph):
Before calling splitUri, detect plain paths (:// absent) and bypass URI parsing. Add null checks after splitUri and ensure defensive handling for "/" and whitespace-only inputs. Consider normalizing early: path = path.trim(); if (path.isEmpty()) return new String[0];.