Subject: | COPY on a directory writes files with wrong content |
Apache::WebDAV::copy() contains the following code for doing recursive
copying:
# Then copy over each file
foreach my $file (reverse sort @files)
{
my $dest_file = $file;
$dest_file =~ s/^$path/$destination/;
my $fh = $handler->open_read($file);
my $contents = join '', <$fh>;
$handler->close_read($fh);
# Don't write if the file exists and overwrite is FALSE
if($handler->test('e', $dest_file) && $overwrite eq 'F')
{
return 401;
}
# Write the new file
$fh = $handler->open_write($dest_file);
print $fh $file;
$handler->close_write($fh);
}
The second line below "#write the new file" is clearly wrong as $file is
the name of the source file and not the content of the file. This line
should read
print $fh $contents
instead.