Skip to content

A quoted path pasted at the "Enter the path" prompt is scanned as <cwd>/"<path>" and reported as "Directory not found" #152

Description

@matt-edmondson

What's wrong

A verb run without -p, including one started from the interactive menu (the default when there are no arguments), prompts for a path. The prompt code is at FileDeduplicator/Verbs/Scan.cs:18-26, and the same code is duplicated in DryRun.cs, Deduplicate.cs and Stats.cs. It only calls .Trim() on the input. BaseVerb.Path (Verbs/BaseVerb.cs:19) then passes the string straight to Path.GetFullPath.

Pasted paths usually arrive in quotes:

  • Explorer's Copy as path always wraps the path in "...".
  • Dragging a folder into a Windows terminal quotes it when the path contains spaces.

The quotes stay in the string as literal characters. GetFullPath then treats the quoted text as a relative name and resolves it under the working directory.

Repro (Linux, built binary)

$ printf '"/tmp/x/q dir"\n' | dotnet ktsu.FileDeduplicator.dll Scan
Enter the path to scan: Scanning: /tmp/x/"/tmp/x/q dir"
Discovering files...
Directory not found: /tmp/x/"/tmp/x/q dir"
Found 0 file(s).

The exit code is 0 (that part is tracked separately in #144).

On Windows, " is not a legal path character. Because of #140, a quoted path there may throw during the AbsoluteDirectoryPath conversion instead of failing the lookup cleanly. That is inferred from #140 and not verified on Windows.

Why it matters

Pasting or dragging a path is the most natural way to answer the prompt, and the menu is the default entry point. The user sees a doubled, confusing path and nothing tells them the quotes caused it.

Suggested fix

  • Move the four copies of the prompt into one shared helper on BaseVerb.
  • After trimming, strip one matching pair of surrounding " or ' characters.

Acceptance criteria

  • Entering "C:\some dir" or '/some dir' at the prompt scans that directory.
  • A test drives the prompt through stdin with a quoted path, using the existing console-capture helpers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions