fpath icon indicating copy to clipboard operation
fpath copied to clipboard

Bad behaviour of split_base and // with Windows paths containing colons

Open stedolan opened this issue 8 years ago • 1 comments

When windows = true, Fpath does this:

# let d, b = split_base (v "A:B:C") in to_string (d // b);;
- : string = "B:C"
# let d, b = split_base (v "\\\\server\\share\\foo:bar") in to_string (d // b);;
- : string = "foo:bar"

(I think colons are invalid in segments of Windows paths, so the issue might be that v allows such silly paths rather than that split_base and // give a strange result)

stedolan avatar May 21 '17 10:05 stedolan

I think colons are invalid in segments of Windows paths

Not entirely, the incredible Windows® path (see this very useful document) allows them if you start your path with \\?\.

So this is what happens:

let d, b = split_base (v "A:B:C") in to_string (d // b);;

  • : string = "B:C"

This gets split into A:, B:C, and the behaviour of append d b is to take b if it is absolute or if it has a volume.

let d, b = split_base (v "\\server\share\foo:bar") in to_string (d // b);;

  • : string = "foo:bar"

This get split info \\\\server\\share\\ and foo:bar according to the second pattern here and then it recognizes foo:bar as a path with a volume and as above append d b will return b.

I have to admit I'm not entirely sure what to do here.

dbuenzli avatar May 24 '17 13:05 dbuenzli