|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59733 trailing spaces trimmed from filenames
Submitted: 2011-04-27 00:21 UTC Modified: 2011-09-21 15:05 UTC
From: dougal at gunters dot org Assigned: bjori (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.2.6 OS: Ubuntu 10.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
36 - 25 = ?
Subscribe to this entry?

 [2011-04-27 00:21 UTC] dougal at gunters dot org
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:
 * 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);
$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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-28 10:15 UTC] dougal at gunters dot org
Okay, I did upgrade the extension to 0.11.2 (current), and the 
bug still exists. Just FYI.
 [2011-04-28 10:31 UTC] dougal at gunters dot org
Oh, and I suppose it's possible that the bug is actually in 
the underlying libssh2 (ver 0.18).
 [2011-09-21 15:05 UTC]
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 21 19:01:29 2024 UTC