New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File::Spec::Functions abs2rel confused by trailing ..s #16666
Comments
From martin.peylo@nokia.comWhen abs2rel gets a path argument with ..s that are crossing over the ..s Example Tested in File::Spec versions Perl Info
|
From @jkeenanOn Wed, 22 Aug 2018 09:12:39 GMT, martin.peylo@nokia.com wrote: Does the program attached correctly describe your problem? (When run as 'prove -v 133465-abs2rel-func.t', the 4th test fails while the 5th test unexpectedly passes.) Thank you very much. -- |
From @jkeenan#!/usr/bin/env perl my $tdir = tempdir(CLEANUP => 1); my $startdir = cwd(); @created = make_path('goal/test', { mode => 0711 }); my $goaldir = File::Spec->catdir($startdir, 'goal'); my $dest = "$testingdir/goal/test/.."; @created = make_path('base', { mode => 0711 }); my $base = "$testingdir/goal/test/../../base"; my $rel_path = abs2rel($dest, $base); done_testing(); sub chdir_test { |
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Wed, 22 Aug 2018 15:15:15 GMT, jkeenan wrote:
Attached is another test file, written with directories named after the style used in dist/PathTools/t/Spec.t, which confirms the problem. The problem lies in this part of the definition of abs2rel() in lib/File/Spec/Unix.pm: ##### To see a version of this block with some debugging code added, see: https://github.com/jkeenan/PathTools/tree/rt-133465-abs2rel Thank you very much. |
From @jkeenan#!/usr/bin/env perl my $od = cwd(); my @d = map { File::Spec->catdir($startdir, File::Spec->splitdir($_)) } ('t1/t2/t3', 't1/t4'); chdir $e[1] or die "Unable to chdir to chdir done_testing; |
From martin.peylo@nokia.comHi, Yes, I guess so - it seems to come to the same conclusion "in real life" as my sample did "virtually". When run as you instruct, it also fails in my environment as you describe. Thank you for picking that up so fast, -----Original Message----- On Wed, 22 Aug 2018 09:12:39 GMT, martin.peylo@nokia.com wrote: Does the program attached correctly describe your problem? (When run as 'prove -v 133465-abs2rel-func.t', the 4th test fails while the 5th test unexpectedly passes.) Thank you very much. -- |
From @jkeenanOn Thu, 23 Aug 2018 14:46:49 GMT, jkeenan wrote:
1. There was one conceptual error in the test file, 133465-spec-abs2rel.t, that I attached to this RT yesterday. So please treat that as superseded. I am attaching a new test file, 2-133465-spec-abs2rel.t, which (a) corrects that error; (b) refactors a lot of the code into subroutines for readability; and (c) adds an additional test case. 2. Sadly, the additional test case added in 1(c) shows that we have even more problems with File::Spec->abs2rel() than that reported originally by Martin Peylo. In the case he reported, there were updirs ('..') in the middle of the base path and an updir at the end of the destination path. The second test case in the attachment pertains to no updirs in the base path and an updir at the end of the destination path. In that case abs2rel() calculates a *valid* relative path -- valid in the sense that if you're in the base directory and use the relative path as the argument to 'chdir', you will get to the expected location -- but not the *simplest* relative path. Instead, in this case abs2rel() calculates a relative path with updirs in it. 3. Not yet examined: cases where there are updirs in the base path. Thank you very much. |
From @jkeenan#!/usr/bin/env perl my $od = cwd(); my $tdir = tempdir(CLEANUP => 1); my $setup_args = { my $chdir_args = { my $use_abs2rel_args = { chdir { my $tdir = tempdir(CLEANUP => 1); my $setup_args = { my $test_args = { my $chdir_args = { my $use_abs2rel_args = { done_testing; #################### SUBROUTINES #################### sub startdir_setup { sub manual_directory_setup { sub confirm_test_paths_created { sub confirm_chdir_via_expected_relpath { sub calculate_relpath_via_abs2rel { |
From @jkeenanOn Fri, 24 Aug 2018 16:09:33 GMT, jkeenan wrote:
For good measure, in attachment 3-133465-spec-abs2rel.t, I have added two more test cases, in each of which the destination path contains updirs ('..') in the middle of the path. These cases give results similar to those in the second block, i.e., abs2rel() composes a relative path which is *valid* for the purpose of chdir-ing from the base path to the destination path but which is not the *simplest* possible spelling of that relative path. Thank you very much. -- |
From @jkeenan#!/usr/bin/env perl my $od = cwd(); note($msg); my $tdir = tempdir(CLEANUP => 1); my $setup_args = { my $chdir_args = { my $use_abs2rel_args = { chdir { note($msg); my $tdir = tempdir(CLEANUP => 1); my $setup_args = { my $test_args = { my $chdir_args = { my $use_abs2rel_args = { { note($msg); my $tdir = tempdir(CLEANUP => 1); my $setup_args = { my $test_args = { my $chdir_args = { my $use_abs2rel_args = { chdir { note($msg); my $tdir = tempdir(CLEANUP => 1); my $setup_args = { my $test_args = { my $chdir_args = { my $use_abs2rel_args = { chdir done_testing; #################### SUBROUTINES #################### sub startdir_setup { sub manual_directory_setup { sub confirm_test_paths_created { sub confirm_chdir_via_expected_relpath { sub calculate_relpath_via_abs2rel { |
Migrated from rt.perl.org#133465 (status was 'open')
Searchable as RT133465$
The text was updated successfully, but these errors were encountered: