file:resolve-path, ".." steps

Monday, 11 July 2022 · 3 messages
HR
Hans-Juergen Rennau11 Jul 2022 12:28 #

Dear BaseX people,

extension function file:resolve-path() shows a behaviour which appears to me inconsistent and probably not intended:

- if called with a single parameter, a path containing ".." is resolved as expected - if called with two parameters, the ".." steps are not resolved.

I would expect the resolution of ".." steps to be always a part of path resolution.

Example:

cd C:\a\b\c

file:resolve-path('../x')

=> C:\a\b\x

file:resolve-path('../x', 'file:///C:/a/b/c/')

=> C:\a\b\c\..\x

file:resolve-path('../x    ', 'file:///C:/a/b/c/' ! file:resolve-path(.)

=> C:\a\b\x

Greetings,

Hans-Jürgen

CG
Christian Grün11 Jul 2022 13:28 #

Hi Hans-Jürgen,

True. The implementations of fn:resolve-uri and file:resolve-path use equivalent functions in Java, which seem to work differently:

https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#resolve-java.nio.file.Path- https://docs.oracle.com/javase/8/docs/api/java/net/URI.html#resolve-java.net.URI-

A bug fix is available [1].

Best, Christian

[1] https://files.basex.org/releases/latest/

Quoted text · Hans-Juergen Rennau · 30 lines
On Mon, Jul 11, 2022 at 12:28 PM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > Dear BaseX people, > > extension function file:resolve-path() shows a behaviour which appears to me inconsistent and probably not intended: > > - if called with a single parameter, a path containing ".." is resolved as expected > - if called with two parameters, the ".." steps are not resolved. > > I would expect the resolution of ".." steps to be always a part of path resolution. > > Example: > > cd C:\a\b\c > > file:resolve-path('../x') > => > C:\a\b\x > > file:resolve-path('../x', 'file:///C:/a/b/c/') > => > C:\a\b\c\..\x > > file:resolve-path('../x ', 'file:///C:/a/b/c/' ! file:resolve-path(.) > => > C:\a\b\x > > Greetings, > Hans-Jürgen >
HR
Hans-Juergen Rennau11 Jul 2022 14:57 #

Wahnsinn! Thank you so much!Hans-Jürgen Am Montag, 11. Juli 2022 um 13:29:33 MESZ hat Christian Grün <christian.gruen at gmail.com> Folgendes geschrieben:

Hi Hans-Jürgen,

True. The implementations of fn:resolve-uri and file:resolve-path use equivalent functions in Java, which seem to work differently:

https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#resolve-java.nio.file.Path- https://docs.oracle.com/javase/8/docs/api/java/net/URI.html#resolve-java.net.URI-

A bug fix is available [1].

Best, Christian

[1] https://files.basex.org/releases/latest/

Quoted text · Hans-Juergen Rennau · 30 lines
On Mon, Jul 11, 2022 at 12:28 PM Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > Dear BaseX people, > > extension function file:resolve-path() shows a behaviour which appears to me inconsistent and probably not intended: > > - if called with a single parameter, a path containing ".." is resolved as expected > - if called with two parameters, the ".." steps are not resolved. > > I would expect the resolution of ".." steps to be always a part of path resolution. > > Example: > > cd C:\a\b\c > > file:resolve-path('../x') > => > C:\a\b\x > > file:resolve-path('../x', 'file:///C:/a/b/c/') > => > C:\a\b\c\..\x > > file:resolve-path('../x ', 'file:///C:/a/b/c/' ! file:resolve-path(.) > => > C:\a\b\x > > Greetings, > Hans-Jürgen >

⚡Generated with XQuery