From ab5e8201f487023dc6f02a43ae522d76300f8e86 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 11 Sep 2014 16:27:10 -0500 Subject: [PATCH] Fix quoting issues in lineinfile for individual single-quotes Fixes #8806 --- files/lineinfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/files/lineinfile b/files/lineinfile index ba842e15e2a..12f8dc89a7d 100644 --- a/files/lineinfile +++ b/files/lineinfile @@ -369,14 +369,19 @@ def main(): # so we need to know if we should specifically unquote it. should_unquote = not is_quoted(line) + # always add one layer of quotes + line = "'%s'" % line + # Replace escape sequences like '\n' while being sure # not to replace octal escape sequences (\ooo) since they # match the backref syntax. if backrefs: line = re.sub(r'(\\[0-9]{1,3})', r'\\\1', line) - line = module.safe_eval(pipes.quote(line)) + line = module.safe_eval(line) - # Now remove quotes around the string, if needed + # Now remove quotes around the string, if needed after + # removing the layer we added above + line = unquote(line) if should_unquote: line = unquote(line)