php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54947 ssh2.sftp protocol wrapper works incorrectly for paths which contain a '#'
Submitted: 2011-05-28 15:42 UTC Modified: 2011-05-30 10:34 UTC
From: josvanbakel at gmail dot com Assigned:
Status: Not a bug Package: *Network Functions
PHP Version: Irrelevant OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: josvanbakel at gmail dot com
New email:
PHP Version: OS:

 

 [2011-05-28 15:42 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

Test script:
---------------
// $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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-29 16:53 UTC] zelnaga at gmail dot com
You'd probably have more success with phpseclib, a pure PHP SFTP implementation:

http://phpseclib.sourceforge.net/

Doesn't absolve the maintainer of the php_ssh2.dll from fixing this bug but it's a work around you can none-the-less use until the problem is fixed.
 [2011-05-29 19:59 UTC] josvanbakel at gmail dot com
Thanks for the tip. I'll give it a try.
 [2011-05-30 10:34 UTC] pajoye@php.net
-Status: Open +Status: Bogus
 [2011-05-30 10:34 UTC] pajoye@php.net
Please report ssh2 bugs to pecl.php.net/ssh2. Also it could be a problem in 
libssh2 itself, I will have to check.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 07:01:30 2024 UTC