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::VMS->canonpath() incorrect with ODS-5 style directory specs #15499
Comments
From levitte@openssl.orgHi, I've found a bug in File::Spec::VMS->canonpath(), when a dash My examples show quite clearly where things go wrong: $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar.coo.kie.--]')" check! $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar^.coo.kie.--]')" WRONG! $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar.coo^.kie.--]')" WRONG! $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar.coo.kie.-]')" check! $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar^.coo.kie.-]')" check! $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar.coo^.kie.-]')" WRONG! I've created a patch (attached) that solves the issue, with these $ perl "-I." -e "require 'VMS.pm'; print File::Spec::VMS->canonpath('foo:[bar.coo.kie.--]')" The tested perl is 5.20.1, but comparing its VMS.pm to the one in the Cheers, -- |
From levitte@openssl.orgVMS.pm.patch--- VMS.pm.1 2016-08-06 22:26:22.987294406 +0200
+++ VMS.pm.2 2016-08-06 23:15:22.226631337 +0200
@@ -94,7 +94,7 @@
# [-.-. ==> [--.
# .-.-] ==> .--]
# [-.-] ==> [--]
- 1 while ($path =~ s/(?<!\^)([\[\.])[^\]\.]+\.-(-+)([\]\.])/$1$2$3/);
+ 1 while ($path =~ s/(?<!\^)([\[\.])(?:\^.|[^\]\.])+\.-(-+)([\]\.])/$1$2$3/);
# That loop does the following
# with any amount (minimum 2)
# of dashes:
@@ -105,11 +105,11 @@
#
# And then, the remaining cases
$path =~ s/(?<!\^)\[\.-/[-/; # [.- ==> [-
- $path =~ s/(?<!\^)\.[^\]\.]+\.-\./\./g; # .foo.-. ==> .
- $path =~ s/(?<!\^)\[[^\]\.]+\.-\./\[/g; # [foo.-. ==> [
- $path =~ s/(?<!\^)\.[^\]\.]+\.-\]/\]/g; # .foo.-] ==> ]
+ $path =~ s/(?<!\^)\.(?:\^.|[^\]\.])+\.-\./\./g; # .foo.-. ==> .
+ $path =~ s/(?<!\^)\[(?:\^.|[^\]\.])+\.-\./\[/g; # [foo.-. ==> [
+ $path =~ s/(?<!\^)\.(?:\^.|[^\]\.])+\.-\]/\]/g; # .foo.-] ==> ]
# [foo.-] ==> [000000]
- $path =~ s/(?<!\^)\[[^\]\.]+\.-\]/\[000000\]/g;
+ $path =~ s/(?<!\^)\[(?:\^.|[^\]\.])+\.-\]/\[000000\]/g;
# [] ==>
$path =~ s/(?<!\^)\[\]// unless $path eq '[]';
return $unix_rpt ? unixify($path) : $path;
|
From @cpansproutOn Sat Aug 06 14:37:04 2016, levitte@openssl.org wrote:
Any chance you could also patch t/Spec.t and add your failing examples? -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
From levitte@openssl.orgIn message <rt-4.0.24-13765-1470525270-1011.128865-94-0@perl.org> on Sat, 06 Aug 2016 16:14:30 -0700, "Father Chrysostomos via RT" <perlbug-followup@perl.org> said: perlbug-followup> On Sat Aug 06 14:37:04 2016, levitte@openssl.org wrote: Certainly! Attached. I hope I got it right. -- |
From levitte@openssl.orgSpec.t.patch--- Spec.t 2016-03-01 13:33:02.000000000 +0100
+++ Spec.t.new 2016-08-07 12:08:19.682779725 +0200
@@ -448,6 +448,13 @@
# During the Perl 5.8 era, FS::Unix stopped eliminating redundant path elements, so mimic that here.
[ "VMS->canonpath('a/../../b/c.dat')", $vms_unix_rpt ? 'a/../../b/c.dat' : '[-.b]c.dat' ],
[ "VMS->canonpath('^<test^.new.-.caret^ escapes^>')", $vms_unix_rpt ? '/<test.new.-.caret escapes>' : '^<test^.new.-.caret^ escapes^>' ],
+# Check that directory specs with caret-dot component is treated correctly
+[ "VMS->canonpath('foo:[bar.coo.kie.--]file.txt')", $vms_unix_rpt ? '/foo/bar/file.txt' : "foo:[bar]file.txt" ],
+[ "VMS->canonpath('foo:[bar^.coo.kie.--]file.txt')", $vms_unix_rpt ? '/foo/file.txt' : "foo:[000000]file.txt" ],
+[ "VMS->canonpath('foo:[bar.coo^.kie.--]file.txt')", $vms_unix_rpt ? '/foo/file.txt' : "foo:[000000]file.txt" ],
+[ "VMS->canonpath('foo:[bar.coo.kie.-]file.txt')", $vms_unix_rpt ? '/foo/bar/coo/file.txt' : "foo:[bar.coo]file.txt" ],
+[ "VMS->canonpath('foo:[bar^.coo.kie.-]file.txt')", $vms_unix_rpt ? '/foo/bar.coo/file.txt' : "foo:[bar^.coo]file.txt" ],
+[ "VMS->canonpath('foo:[bar.coo^.kie.-]file.txt')", $vms_unix_rpt ? '/foo/bar/file.txt' : "foo:[bar]file.txt" ],
[ "VMS->splitdir('')", '' ],
[ "VMS->splitdir('[]')", '' ],
|
From @craigberryOn Sun, Aug 7, 2016 at 5:22 AM, Richard Levitte <levitte@openssl.org> wrote:
This looks right to me, thanks. It will probably be a couple days |
From @craigberryOn Mon, Aug 8, 2016 at 11:10 AM, Craig A. Berry <craig.a.berry@gmail.com> wrote:
The patch with tests is in at: <http://perl5.git.perl.org/perl.git/commitdiff/e11f7a82751877fddd83adf7de4c5c15d0df3d33> The ticket can be closed, but I will just note that other platforms $ perl -MFile::Spec::Functions -e 'print The '../../' is still there after canonization. Perhaps we should |
@cpansprout - Status changed from 'open' to 'pending release' |
From levitte@openssl.orgCraig Berry via RT <perlbug-followup@perl.org> skrev: (9 augusti 2016 22:34:03 CEST)
Frankly, I'm not sure I understand why it's done that way. Maybe something with samplings and what "going up" would mean, semantically?
I think that's a real bad idea. Just my opinion, but I'd ask the VMS community before making such a drastic change...
Great. Cheers -- |
From @craigberryOn Tue, Aug 9, 2016 at 4:14 PM, Richard Levitte <levitte@openssl.org> wrote:
I don't know either, but apparently it was done in the 5.8 era based
I don't really have a dog in this fight and am short on tuits to do |
From @tonycozOn Tue Aug 09 17:07:05 2016, craig.a.berry@gmail.com wrote:
If coo.kie is a symbolic link to /bar/foo/quux the original path refers to /bar/file.txt If you do a naïve resolution of the ../ you get: /foo/file.txt (remembering canonpath doesn't check the filesystem.) This is noted in the File::Spec documentation for canonpath() - I Tony |
From levitte@openssl.orgTony Cook via RT <perlbug-followup@perl.org> skrev: (10 augusti 2016 02:26:33 CEST)
I suggest closing this ticket if it hasn't already been done. As for symbolic links, issue understood on the Unix side. As for the VMS side, symbolic links do exist but are a very recent addition. I'm thinking of looking into that in the coming weeks. Cheers -- |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.26.0, this and 210 other issues have been Perl 5.26.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#128865 (status was 'resolved')
Searchable as RT128865$
The text was updated successfully, but these errors were encountered: