php.net |  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 (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.3.3 OS: Ubuntu 10.10
Private report: No CVE-ID: None
 [2011-05-30 10:21 UTC] josvanbakel at gmail dot com
Description:
------------
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:

#Test/
    a
Test#/
    b
Test/
    c

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");

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-16 12:48 UTC] langemeijer@php.net
-Status: Open +Status: Verified
 [2012-06-16 12:48 UTC] langemeijer@php.net
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] langemeijer@php.net
Automatic comment from SVN on behalf of langemeijer
Revision: http://svn.php.net/viewvc/?view=revision&revision=326193
Log: Fix bug #59794
 [2012-06-16 13:46 UTC] langemeijer@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: langemeijer
 [2012-06-16 13:46 UTC] langemeijer@php.net
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.
 [2015-11-06 20:38 UTC] ken at pardiac dot com
The fix for bug 59794 has side effects which cause the failures described in bug 69981.  I have posted a patch to 69981 which will correct these failures and also preserve the ability to work with files containing "#" and "?".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 17:01:32 2024 UTC