Make sure we only use unquote on quoted lines in lineinfile when needed

This commit is contained in:
James Cammarata 2014-08-11 11:22:59 -05:00
commit 83fa9a8cde
2 changed files with 17 additions and 6 deletions

View file

@ -187,9 +187,12 @@ def split_args(args):
return params
def is_quoted(data):
return len(data) > 0 and (data[0] == '"' and data[-1] == '"' or data[0] == "'" and data[-1] == "'")
def unquote(data):
''' removes first and last quotes from a string, if the string starts and ends with the same quotes '''
if len(data) > 0 and (data[0] == '"' and data[-1] == '"' or data[0] == "'" and data[-1] == "'"):
if is_quoted(data):
return data[1:-1]
return data