AmazeFileManager icon indicating copy to clipboard operation
AmazeFileManager copied to clipboard

[getPathsInPath] Plain/whitespace path without scheme triggers splitUri NPE

Open wassdak opened this issue 2 months ago • 0 comments

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];.

wassdak avatar Nov 11 '25 02:11 wassdak