Skip to content

Conversation

@owenthereal
Copy link

Summary

Fix cleanPathWithBase to use filepath.IsAbs on the original path before converting to forward slashes. This correctly handles Windows paths like C:\foo which filepath.IsAbs recognizes but path.IsAbs (after ToSlash conversion to C:/foo) does not.

Problem

When using WithStartDirectory on Windows, absolute paths like C:\Users\foo are incorrectly treated as relative paths because:

  1. filepath.ToSlash(filepath.Clean("C:\\Users\\foo"))C:/Users/foo
  2. path.IsAbs("C:/Users/foo")false (only checks for / prefix)
  3. Result: path gets joined with start directory, causing doubled paths

Solution

Check filepath.IsAbs(p) on the original path before the ToSlash conversion. filepath.IsAbs is platform-aware and correctly identifies Windows absolute paths.

Related

This fix resolves Windows SFTP path handling issues in owenthereal/upterm#440

Use filepath.IsAbs on the original path before converting to forward
slashes. This correctly handles Windows paths like "C:\foo" which
filepath.IsAbs recognizes but path.IsAbs (after ToSlash conversion
to "C:/foo") does not.
@puellanivis
Copy link
Collaborator

Remote paths to windows servers require absolute paths to be encoded as /C:/path/to/file.

This is not a bug.

@puellanivis puellanivis reopened this Jan 13, 2026
@puellanivis
Copy link
Collaborator

puellanivis commented Jan 13, 2026

I keep thinking I’m missing something here.

I’m thinking I need this explained better. This code is only called from within the RequestServer, and only on paths coming from a remote client. Where, like I said, any absolute path coming from a client to a windows server must be encoded as /c:/path/to/file, but I can’t shake the feeling that I’m missing something that I should be able to see…

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants