php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dougal at gunters dot org
New email:
PHP Version: OS:

 

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

Patches

Pull Requests

History

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] bjori@php.net
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 pecl.php.net.

In case this was a pecl.php.net 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: Sun Dec 22 11:01:30 2024 UTC