From 38f1bd487f19c8259320a5f4d0e661a6c66269e1 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sat, 25 Jun 2011 15:06:43 +0000 Subject: [PATCH] /home and /home/ should return the same thing for rawlist() and nlist() (thanks pioyu!) git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@167 21d32557-59b3-4da0-833f-c5933fad653e --- phpseclib/Net/SFTP.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index ecae510f..93a2ca39 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -478,12 +478,12 @@ class Net_SFTP extends Net_SSH2 { // if the SFTP server returned the canonicalized path even for non-existant files this wouldn't be necessary // on OpenSSH it isn't necessary but on other SFTP servers it is. that and since the specs say nothing on // the subject, we'll go ahead and work around it with the following. - if ($dir[strlen($dir) - 1] != '/') { + if (empty($dir) || $dir[strlen($dir) - 1] != '/') { $file = basename($dir); $dir = dirname($dir); } - $dir = rtrim($dir, '/'); + $dir = $dir[0] == '/' ? '/' . rtrim(substr($dir, 1), '/') : rtrim($dir, '/'); if ($dir == '.' || $dir == $this->pwd) { return $this->pwd . $file;