abcl icon indicating copy to clipboard operation
abcl copied to clipboard

[bug] ABCL should not auto-normalize `..` found in pathname directory components

Open fosskers opened this issue 1 year ago • 2 comments

I maintain a filepath-handling library, and during some tests noticed that ABCL is over-aggressive about how it handles .. on Unix systems. In particular, it seems to be confusing the difference between :up and :back as described in the spec here.

The issue is that in general, for some given filepath, due to the possibility of symlinks, .. cannot be resolved without a filesystem probe. ABCL is not doing such a probe, but instead assuming that all .. are treated as :back. The perhaps safer thing to do is simply insert a :up where ever a .. is seen, which it seems to only being doing when the previously processed path component was not a string.

Example:

(pathname "/foo/bar/.././../baz/test.json")
=> #P"/foo/baz/test.json"

whereas I would have expected #P"/foo/bar/.././../baz/test.json".

Inspect output:

A pathname.
Namestring: "/foo/baz/test.json"
Host: NIL
Device: NIL
Directory: (:ABSOLUTE "foo" "baz")
Name: "test"
Type: "json"
Version: NIL

This occurs in calls to pathname and in usage of #p pathname literals.

Related https://github.com/Clozure/ccl/issues/477

fosskers avatar Jun 16 '24 12:06 fosskers

Shouldn't it give #P"/baz/test.json"

crmsnbleyd avatar Dec 23 '24 13:12 crmsnbleyd

Because of symlinks, there's no way to guarantee that transformation.

fosskers avatar Dec 23 '24 21:12 fosskers