Skip to content

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

@wassdak

Description

@wassdak

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

Metadata

Metadata

Assignees

No one assigned

    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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions