touki653 / php-ftp-wrapper

A fully object oriented library for PHP FTP functions
MIT License
76 stars 16 forks source link

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

Open therealmikz opened 8 years ago

therealmikz commented 8 years ago

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 commented 8 years ago

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

errb commented 8 years ago

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