php-ftp-wrapper icon indicating copy to clipboard operation
php-ftp-wrapper copied to clipboard

FTP::directoryExists returns false if any ancestor directory contains spaces

Open therealmikz opened this issue 9 years ago • 2 comments

Example (assuming that /foo bar/baz exists): $ftp->directoryExists('/foo bar/baz'); //false

My PHP version: PHP 5.5.9-1ubuntu4.17 (cli) (built: May 19 2016 19:05:57) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

therealmikz avatar Aug 04 '16 15:08 therealmikz

I found that escaping spaces resolves that problem. I'd post PR if I could, but unfortunately can't get unit tests to pass on my configuration. Here's solution:

$dirName = preg_replace('/(?<!\\\\) /', '\\ ', $dirName);

therealmikz avatar Aug 04 '16 16:08 therealmikz

This solution does not work if you use findFileByName or findDirectoryByName methods. This PR probably broke it #7

errb avatar Aug 08 '16 13:08 errb