Skip to content

sftp.get() fails on files containing '%' when local_is_path is true. #711

@jawnb

Description

@jawnb

The path interpolation done in sftp.py on line 118 causes the get() call to break if the filename contains the format string operator (%).

Here's an easy way to reproduce the issue:

def test_case():
    run('mkdir -p /tmp/interpolation_test')
    run('touch /tmp/interpolation_test/%f.txt')
    get('/tmp/interpolation_test', '/tmp')

Raises this:

Fatal error: get() encountered an exception while downloading '/tmp/interpolation_test'

Traceback (most recent call last):
  File "...fabric/operations.py", line 552, in get
    result = ftp.get_dir(remote_path, local_path)
  File "...fabric/sftp.py", line 190, in get_dir
    result.append(self.get(rpath, lpath, True, rremote))
  File "...fabric/sftp.py", line 118, in get
    local_path = os.path.abspath(local_path % path_vars)
TypeError: float argument required, not dict

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions