Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix bug #68260
File::Find was not resolving paths of the form "/..////../" correctly.
Fixed by adding a quantifier to the substitution parameter in
contract_name().
  • Loading branch information
Abigail committed Nov 20, 2009
1 parent d521341 commit 51393fc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/File/Find.pm
Expand Up @@ -448,7 +448,7 @@ sub contract_name {
my $abs_name= $cdir . $fn;

if (substr($fn,0,3) eq '../') {
1 while $abs_name =~ s!/[^/]*/\.\./!/!;
1 while $abs_name =~ s!/[^/]*/\.\./+!/!;
}

return $abs_name;
Expand Down
39 changes: 38 additions & 1 deletion lib/File/Find/t/find.t
Expand Up @@ -95,13 +95,17 @@ sub cleanup {
file_path('fa', 'faa', 'faa_ord'),
file_path('fa', 'fab', 'fab_ord'),
file_path('fa', 'fab', 'faba', 'faba_ord'),
file_path('fa', 'fac', 'faca'),
file_path('fb', 'fb_ord'),
file_path('fb', 'fba', 'fba_ord');
file_path('fb', 'fba', 'fba_ord'),
file_path('fb', 'fbc', 'fbca');
rmdir dir_path('fa', 'faa');
rmdir dir_path('fa', 'fab', 'faba');
rmdir dir_path('fa', 'fab');
rmdir dir_path('fa', 'fac');
rmdir dir_path('fa');
rmdir dir_path('fb', 'fba');
rmdir dir_path('fb', 'fbc');
rmdir dir_path('fb');
}
if ($need_updir) {
Expand Down Expand Up @@ -893,3 +897,36 @@ if ($^O eq 'MSWin32') {
File::Find::find( {wanted => \&wanted_File_Dir, no_chdir => 1}, $volume . topdir('fa'));
Check( scalar(keys %Expect_File) == 0 );
}


if ($symlink_exists) { # Issue 68260
print "# BUG 68260\n";
MkDir (dir_path ('fa', 'fac'), 0770);
MkDir (dir_path ('fb', 'fbc'), 0770);
touch (file_path ('fa', 'fac', 'faca'));
if ($^O eq 'MacOS') {
CheckDie (symlink ('..::::..:fa:fac:faca', 'fb:fbc:fbca'));
}
else {
CheckDie (symlink ('..////../fa/fac/faca', 'fb/fbc/fbca'));
}

use warnings;
my $dangling_symlink;
local $SIG {__WARN__} = sub {
local $" = " ";
$dangling_symlink ++ if "@_" =~ /dangling symbolic link/;
};

File::Find::find (
{
wanted => sub {1;},
follow => 1,
follow_skip => 2,
dangling_symlinks => 1,
},
File::Spec -> curdir
);

Check (!$dangling_symlink);
}

0 comments on commit 51393fc

Please sign in to comment.