diff options
author | btimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-04-20 17:52:51 +0000 |
---|---|---|
committer | btimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-04-20 17:52:51 +0000 |
commit | fd57643110bffbf194b1de664703fba16df34262 (patch) | |
tree | a5e01ca1a062ec23ab3c2623450d67f2d146afe3 | |
parent | 49c744fe60b4944fedaeb9a8a4e493d92f5ac30b (diff) | |
download | pyfilesystem-fd57643110bffbf194b1de664703fba16df34262.tar.gz |
Handle case where client tries to cd .. in /. Nothing nefarious, accidentally clicking ".." in FileZilla causes this.
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@773 67cdc799-7952-0410-af00-57a81ceafa0f
-rw-r--r-- | fs/expose/sftp.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/expose/sftp.py b/fs/expose/sftp.py index 11b6d35..a5bf9f9 100644 --- a/fs/expose/sftp.py +++ b/fs/expose/sftp.py @@ -183,7 +183,14 @@ class SFTPServerInterface(paramiko.SFTPServerInterface): return paramiko.SFTP_OK def canonicalize(self, path): - return abspath(normpath(path)).encode(self.encoding) + try: + return abspath(normpath(path)).encode(self.encoding) + except ValueError, e: + # If the client tries to use backrefs to escape root, gently + # nudge them back to /. + if 'too many backrefs' in e.args[0]: + return '/' + raise @report_sftp_errors def chattr(self, path, attr): |