|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59794 ssh2.sftp protocol wrapper works incorrectly for paths which contain a '#'
Submitted: 2011-05-30 10:21 UTC Modified: 2012-06-16 13:46 UTC
From: josvanbakel at gmail dot com Assigned: langemeijer
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.3.3 OS: Ubuntu 10.10
Private report: No CVE-ID:
 [2011-05-30 10:21 UTC] josvanbakel at gmail dot com
When trying to read a file or directory via the ssh2.sftp protocol wrapper which contains a '#' in the path ssh2.sftp will ignore it. It looks like it treats the '#' as a start comment command (e.g. // in PHP)

In the test script, i have used the following directory structure:


Note that creating the directories from the bash shell requires escaping the # with a \, e.g.: mkdir \#Test

Reproduce code:
// $sftp is a ssh2_sftp resource
// $dir is the directory containing the test directory structure (see description)
$root = "ssh2.sftp://$sftp/$dir";

$a = scandir("$root/#Test");
// $a = array(".", "..", "#Test", "Test#", "Test");
// Note that $a is a dir listing of $root, everything after the # is ignored

$b = scandir("$root/Test#");
// $b = array(".", "..", "c");
// Gives a listing of Test not of Test#

Expected result:
$a = array(".", "..", "a");
$b = array(".", "..", "b");

Actual result:
$a = array(".", "..", "#Test", "Test#", "Test");
$b = array(".", "..", "c");


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-16 12:48 UTC]
-Status: Open +Status: Verified
 [2012-06-16 12:48 UTC]
This is very annoying and happens for all protocol wrappers. See bug #47202 (same 
for FTP)

It would require a change in the way PHP calls the extension. Nothing I can fix 
right now, as I do ssh2, not PHP core.

I'll try and poke some core guys on this issue, and see what happens.
 [2012-06-16 13:42 UTC]
Automatic comment from SVN on behalf of langemeijer
Log: Fix bug #59794
 [2012-06-16 13:46 UTC]
-Status: Verified +Status: Closed -Assigned To: +Assigned To: langemeijer
 [2012-06-16 13:46 UTC]
I was wrong @12:48. I read the FTP bug and concluded this must be the same for 
ssh2 too. It turns out the FTP wrapper can probably be fixed too.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sun Oct 04 07:01:31 2015 UTC