Fix quoting issues in lineinfile for individual single-quotes

Fixes #8806
reviewable/pr18780/r1
James Cammarata 10 years ago
parent 732b6f0a23
commit ab5e8201f4

@ -369,14 +369,19 @@ def main():
# so we need to know if we should specifically unquote it. # so we need to know if we should specifically unquote it.
should_unquote = not is_quoted(line) should_unquote = not is_quoted(line)
# always add one layer of quotes
line = "'%s'" % line
# Replace escape sequences like '\n' while being sure # Replace escape sequences like '\n' while being sure
# not to replace octal escape sequences (\ooo) since they # not to replace octal escape sequences (\ooo) since they
# match the backref syntax. # match the backref syntax.
if backrefs: if backrefs:
line = re.sub(r'(\\[0-9]{1,3})', r'\\\1', line) 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: if should_unquote:
line = unquote(line) line = unquote(line)

Loading…
Cancel
Save