1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Attempted, but failed, to reproduce bug 22403.

This commit is contained in:
Micah Cowan 2009-09-07 22:40:25 -07:00
parent 1e5a791a22
commit aab7dadc9a
5 changed files with 89 additions and 2 deletions

View File

@ -1,3 +1,14 @@
2009-09-07 Micah Cowan <micah@cowan.name>
* FTPServer.pm (FTPServer::run): Pass "server behavior" information to
newly-constructed FTPPaths object.
(FTPPaths::initialize): Accept "server behavior" hash.
(FTPPaths::_format_for_list): If server behavior has "bad_list"
set, then always report 0 for the size.
* Test-ftp-bad-list.px: Added. Attempts to reproduce bug
22403... but doesn't.
* run-px, Makefile.am (EXTRA_DIST): Added Test-ftp-bad-list.px.
2009-09-06 Micah Cowan <micah@cowan.name>
* WgetTest.pm.in (_setup): Don't expect error codes from

View File

@ -563,7 +563,8 @@ sub run
print STDERR "in child\n" if $log;
my $conn = {
'paths' => FTPPaths->new($self->{'_input'}),
'paths' => FTPPaths->new($self->{'_input'},
$self->{'_server_behavior'}),
'socket' => $socket,
'state' => $_connection_states{NEWCONN},
'dir' => '/',
@ -693,7 +694,7 @@ sub new {
}
sub initialize {
my ($self, $urls) = @_;
my ($self, $urls, $behavior) = @_;
my $paths = {_type => 'd'};
# From a path like '/foo/bar/baz.txt', construct $paths such that
@ -714,6 +715,7 @@ sub initialize {
}
$self->{'_paths'} = $paths;
$self->{'_behavior'} = $behavior;
}
sub get_info {
@ -763,6 +765,9 @@ sub _format_for_list {
my $size = 0;
if ($info->{'_type'} eq 'f') {
$size = length $info->{'content'};
if ($self->{'_behavior'}{'bad_list'}) {
$size = 0;
}
}
my $date = strftime ("%b %e %H:%M", localtime);
return "$mode_str 1 0 0 $size $date $name";

View File

@ -74,6 +74,7 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
Test-E-k.px \
Test-ftp.px \
Test-ftp-pasv-fail.px \
Test-ftp-bad-list.px \
Test-ftp-recursive.px \
Test-ftp-iri.px \
Test-ftp-iri-fallback.px \

69
tests/Test-ftp-bad-list.px Executable file
View File

@ -0,0 +1,69 @@
#!/usr/bin/perl
use strict;
use warnings;
use FTPTest;
###############################################################################
my $afile = <<EOF;
Some text.
EOF
my $bfile = <<EOF;
Some more text.
EOF
$afile =~ s/\n/\r\n/g;
$bfile =~ s/\n/\r\n/g;
# code, msg, headers, content
my %urls = (
'/afile.txt' => {
content => $afile,
},
'/bfile.txt' => {
content => $bfile,
},
);
my $cmdline = $WgetTest::WGETPATH . " -d -nH -Nc -r ftp://localhost:{{port}}/";
my $expected_error_code = 0;
# Don't need to worry about timestamps, the "bad_list" setting will
# ensure the sizes don't match expectations, and so they'll always be
# re-downloaded.
my %expected_downloaded_files = (
'afile.txt' => {
content => $afile,
},
'bfile.txt' => {
content => $bfile,
},
);
my %preexisting_files = (
'afile.txt' => {
content => $afile,
},
'bfile.txt' => {
content => $bfile,
},
);
###############################################################################
my $the_test = FTPTest->new (name => "Test-ftp-bad-list",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files,
existing => \%preexisting_files,
server_behavior => {bad_list => 1});
exit $the_test->run();
# vim: et ts=4 sw=4

View File

@ -27,6 +27,7 @@ my @tests = (
'Test-E-k.px',
'Test-ftp.px',
'Test-ftp-pasv-fail.px',
'Test-ftp-bad-list.px',
'Test-ftp-recursive.px',
'Test-ftp-iri.px',
'Test-ftp-iri-fallback.px',