|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-04-28 10:15 UTC] dougal at gunters dot org
[2011-04-28 10:31 UTC] dougal at gunters dot org
[2011-09-21 15:05 UTC] bjori@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
Description: ------------ When using dir() on an ssh2.sftp resource, filenames with spaces at the end (e.g., 'foo.txt ') get trimmed. Any further file operations on such an entry will fail. Note: I have the 0.11.0-dev version of the ssh2 extension installed. It is impractical for me to upgrade or set up a test environment for 0.11.2 at this time. I did try searching for existing bug reports on this, but did not find one. Reproduce code: --------------- <?php /* * First, create a file with trailing space in filename * in the dest dir. E.g.: touch "foo.txt " * Then, run this php script. */ $link = ssh2_connect('localhost', 22); ssh2_auth_password($link,'myusername','mypassword'); $sftp = ssh2_sftp($link); $dir = @dir('ssh2.sftp://' . $sftp . '/home/myusername/test'); if ( ! $dir ) { die("Could not read dir via ssh2.sftp.\n"); } while (false !== ($entry = $dir->read()) ) { echo "'$entry'\t" . filemtime($entry) . "\t" . filesize($entry) . "\n"; } Expected result: ---------------- The entry for the 'foo.txt ' file should work just as for any other file, printing the filename, size, and timestamp. Actual result: -------------- Warning: filemtime(): stat failed for foo.txt in /home/dougal/test/test.php on line 14 Warning: filesize(): stat failed for foo.txt in /home/dougal/test/test.php on line 14 'foo.txt'