Skip to content

QA - ftp_rawlist - check list return value #9012

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions ext/ftp/tests/ftp_rawlist_basic1.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Testing ftp_rawlist basic functionality
--CREDITS--
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know if doing this was right honeslty ... I was told that --CREDITS-- was not suppose to be use anymore

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually do not remove already existing CREDITS, but in this case it might be okay. @carusogabriel, or do you object?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay, no worries from my side on removing all mine CREDITS in tests :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually do not remove already existing CREDITS, but in this case it might be okay. @carusogabriel, or do you object?

That is what I thought but I was not sure, I will add it again, is ethically correct to keep them

Gabriel Caruso ([email protected])
--EXTENSIONS--
ftp
pcntl
Expand All @@ -13,7 +11,19 @@ $ftp = ftp_connect('127.0.0.1', $port);
ftp_login($ftp, 'user', 'pass');
$ftp or die("Couldn't connect to the server");

var_dump(is_array(ftp_rawlist($ftp, 'www/')));
$result = ftp_rawlist($ftp, 'www/');
var_dump(is_array($result));
var_dump($result);
ftp_close($ftp);
?>
--EXPECT--
bool(true)
array(3) {
[0]=>
string(5) "file1"
[1]=>
string(5) "file1"
[2]=>
string(9) "file
b0rk"
}
21 changes: 20 additions & 1 deletion ext/ftp/tests/server.inc
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,27 @@ if ($pid) {
fputs($s, "200 " . $matches[1] . " bytes allocated\r\n");

}elseif (preg_match('/^LIST www\//', $buf, $matches)) {
fputs($s, "226 Transfer complete\r\n");
if (empty($pasv)) {
fputs($s, "150 File status okay; about to open data connection\r\n");
if (!$fs = stream_socket_client("tcp://$host:$port")) {
fputs($s, "425 Can't open data connection\r\n");
continue;
}
} else {
fputs($s, "125 Data connection already open; transfer starting.\r\n");
$fs=$pasvs;
}


if ((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) {
die("SSLv23 handshake failed.\n");
}

fputs($fs, "file1\r\nfile1\r\nfile\nb0rk\r\n");
fputs($s, "226 Closing data Connection.\r\n");
fclose($fs);

fputs($s, "226 Transfer complete\r\n");
}elseif (preg_match('/^LIST no_exists\//', $buf, $matches)) {
fputs($s, "425 Error establishing connection\r\n");

Expand Down