From 16e393b61d53843dfec3b88257925a0848c027ed Mon Sep 17 00:00:00 2001
From: Andreas Fischer <bantu@phpbb.com>
Date: Wed, 22 Jul 2009 03:02:45 +0000
Subject: Also fix bug #46295 in ftp_fsock class.

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9822 89ea8834-ac86-4346-8a33-228a782c2dd0
---
 phpBB/includes/functions_transfer.php | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

(limited to 'phpBB/includes/functions_transfer.php')

diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php
index 7c5cd329a4..046abede8e 100644
--- a/phpBB/includes/functions_transfer.php
+++ b/phpBB/includes/functions_transfer.php
@@ -483,7 +483,7 @@ class ftp extends transfer
 			$item = str_replace('\\', '/', $item);
 			$dir = str_replace('\\', '/', $dir);
 
-			if (strpos($item, $dir) === 0)
+			if (!empty($dir) && strpos($item, $dir) === 0)
 			{
 				$item = substr($item, strlen($dir));
 			}
@@ -749,6 +749,20 @@ class ftp_fsock extends transfer
 		// Clear buffer
 		$this->_check_command();
 
+		// See bug #46295 - Some FTP daemons don't like './'
+		if ($dir === './' && empty($list))
+		{
+			// Let's try some alternatives
+			$list = $this->_ls('.');
+
+			if (empty($list))
+			{
+				$list = $this->_ls('');
+			}
+
+			return $list;
+		}
+
 		// Remove path if prepended
 		foreach ($list as $key => $item)
 		{
@@ -756,7 +770,7 @@ class ftp_fsock extends transfer
 			$item = str_replace('\\', '/', $item);
 			$dir = str_replace('\\', '/', $dir);
 
-			if (strpos($item, $dir) === 0)
+			if (!empty($dir) && strpos($item, $dir) === 0)
 			{
 				$item = substr($item, strlen($dir));
 			}
-- 
cgit v1.2.1