armedbear / abcl

Armed Bear Common Lisp <git+https://github.com/armedbear/abcl/> <--> <svn+https://abcl.org/svn> Bridge
https://abcl.org#rdfs:seeAlso<https://gitlab.common-lisp.net/abcl/abcl>
Other
288 stars 29 forks source link

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

Open fosskers opened 2 months ago

fosskers commented 2 months ago

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