Skip to content

fix single quote escape for append, contains #36

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nixon
Copy link

@nixon nixon commented Oct 20, 2019

revert back to fabric1 version of _escape_for_regex to handle single
quotes and other special characters.

also escaped double quotes in filename and added testcases.

refs #34

revert back to fabric1 version of `_escape_for_regex` to handle single
quotes and other special characters.

also escaped double quotes in filename and added testcases.

refs fabric#34
@nixon
Copy link
Author

nixon commented Oct 20, 2019

I also used this test script to make sure things were working outside the test mock environment:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tempfile

from invoke import Context
from fabric import task
from patchwork.files import append


@task
def testcases(c, fname):
    expected = [
        "alias l='ls -rtl'",
        'trailing $',
        'trailing $$',
        'an env var is not expanded: $HOME',
        "trailing single quote '",
        'trailing double quote "',
        'trailing backtick `',
        'backticks dont execute `id`',
        'no command substitution $(id)',
        '',  # an empty line
        'a single \\ backslash',
        'a single trailing backslash \\',
        "listen_addresses = '*'",
    ]

    for line in expected:
        append(c, fname, line)

    actual = open(fname).read().strip()

    assert actual == '\n'.join(expected), actual


def runtests():
    c = Context()

    with tempfile.NamedTemporaryFile() as f:
        testcases(c, f.name)
        testcases(c, f.name)


if __name__ == "__main__":
    runtests()

@nixon
Copy link
Author

nixon commented Oct 20, 2019

FWIW, I think the Travis failures are related to a recent semantic-version change. If I pin to semantic-version<2.7, then I don't get that ValueError: Call either Version('1.2.3') or Version(major=1, ...) anymore.

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

Successfully merging this pull request may close these issues.

1 participant