Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List command does not work with path containing apostrophe character #55

Closed
codeanywhere opened this issue Jul 30, 2013 · 5 comments
Closed

Comments

@codeanywhere
Copy link

List command fails to return file list when there is apostrophe (') char in the path parameter (for example "public_html/test's dir"), although it does not return any error.

@mscdex
Copy link
Owner

mscdex commented Jul 30, 2013

I tried duplicating this locally (with FileZilla Server) but it works for me.

@codeanywhere
Copy link
Author

I've created you test ftp account so you can test it directly. The server is CentOs with cpanel/whm software, regular web hosting account.

host: 50.28.85.148
user: a1sb
pass: testpass

There are two folders inside public_html: "app" and "app' 2", they have identical content, but first one returns file list and second returns empty list.

@mscdex
Copy link
Owner

mscdex commented Jul 31, 2013

Ok, so it looks like the behavior is undefined with paths like this. Implementations seem to differ when it comes to handling paths with spaces, quotes, and the like.

At this point I would probably do something like what the FileZilla client does, which is: change to the directory, do a list, and then change back. Something like this:

function sillylist(path, cb) {
  if (typeof path === 'string') {
    // store current path
    c.pwd(function(err, origpath) {
      if (err) return cb(err);
      // change to destination path
      c.cwd(path, function(err) {
        if (err) return cb(err);
        // get dir listing
        c.list(function(err, list) {
          // change back to original path
          if (err) return c.cwd(origpath, cb);
          c.cwd(origpath, function(err) {
            if (err) return cb(err);
            cb(err, list);
          });
        });
      });
    });
  } else
    c.list(path, cb);
}

I believe that should work for all implementations no matter the characters in the path. I am thinking about possibly adding this as a separate, "safe" version of list() to avoid this kind of thing in the future.

@codeanywhere
Copy link
Author

Using a CWD command works for me. Thank you!

@alireza79792000
Copy link

Love

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants