Skip to content

canonicalizePath does not fully canonicalize paths that contain dangling links #64

Closed
@Rufflewind

Description

@Rufflewind

If you create a link brokenlink that points to a nonexistent file and then run canonicalizePath on brokenlink, you still get brokenlink back because the link is dangling. I think it makes more sense to return nonexistent instead.

Fixing this however, is quite tricky. The reason is that we can't trust realpath will work correctly on a nonexistent path: on Macs realpath has strange behavior with nonexistent paths (#23), and on Windows the “realpath”-equivalent (GetFinalPathName) requires an existing file to even work.

So this means our only option is to implement it using a readlink (or equivalent). But it may take more than one readlink calls to make this work, if there are more symbolic link components in the new path, Worse potentially this might loop, so we'd need a cutoff too.

All in all, this is (IMO) a fairly minor thing, but requires a lot of effort and testing to get right.

Metadata

Metadata

Assignees

Labels

type: a-bugThe described behavior is not working as intended.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions