summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-03-27 18:07:30 +0000
committerDavid Mitchell <davem@iabyn.com>2010-03-27 18:12:39 +0000
commitfff5c6e2d16a6c4070b5580acb55b3663ed90c08 (patch)
tree3374e097d7fa80c3ab27973825fd0385034d17f0 /lib
parent94e9284742fce739393f3ccf1f443b4486b689cc (diff)
downloadperl-fff5c6e2d16a6c4070b5580acb55b3663ed90c08.tar.gz
RT #73714: Regression in 5.12: File::Copy and initial spaces
Commit 81ec4fbc8320b72171c9fbea0fa0456b3a687f92 removed some obsolete code that processed with leading spaces in filenames (not needed with 3-arg open), but didn't quite clean out everything. This meant that trying to copy to a file whose name had a leading space would unceremoniously die with Undefined subroutine &File::Copy::_protect called
Diffstat (limited to 'lib')
-rw-r--r--lib/File/Copy.pm5
-rw-r--r--lib/File/Copy.t13
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm
index 4dc8c6dc01..c3823acad8 100644
--- a/lib/File/Copy.pm
+++ b/lib/File/Copy.pm
@@ -22,7 +22,7 @@ sub syscopy;
sub cp;
sub mv;
-$VERSION = '2.17';
+$VERSION = '2.18';
require Exporter;
@ISA = qw(Exporter);
@@ -242,8 +242,7 @@ sub copy {
if ($to_a_handle) {
$to_h = $to;
} else {
- $to = _protect($to) if $to =~ /^\s/s;
- $to_h = \do { local *FH };
+ $to_h = \do { local *FH }; # XXX is this line obsolete?
open $to_h, ">", $to or goto fail_open2;
binmode $to_h or die "($!,$^E)";
$closeto = 1;
diff --git a/lib/File/Copy.t b/lib/File/Copy.t
index 2644bce024..cc1c3ffccf 100644
--- a/lib/File/Copy.t
+++ b/lib/File/Copy.t
@@ -14,7 +14,7 @@ use Test::More;
my $TB = Test::More->builder;
-plan tests => 461;
+plan tests => 463;
# We're going to override rename() later on but Perl has to see an override
# at compile time to honor it.
@@ -223,6 +223,17 @@ for my $cross_partition_test (0..1) {
unlink "file-$$" or die $!;
unlink "copy-$$" or die $!;
+
+ # RT #73714 copy to file with leading whitespace failed
+
+ open(F, ">file-$$") or die $!;
+ close F;
+ copy "file-$$", " copy-$$";
+ warn "XXX\n";
+ ok -e " copy-$$", "copy with leading whitespace";
+ unlink "file-$$" or die "unlink: $!";
+ unlink " copy-$$" or die "unlink: $!";
+
}