mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
use the right way to unescape line string Reference https://github.com/ansible/ansible/issues/10864
This commit is contained in:
@@ -22,7 +22,6 @@
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import pipes
|
import pipes
|
||||||
import codecs
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
@@ -370,22 +369,6 @@ def main():
|
|||||||
|
|
||||||
line = params['line']
|
line = params['line']
|
||||||
|
|
||||||
# The safe_eval call will remove some quoting, but not others,
|
|
||||||
# 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(line)
|
|
||||||
|
|
||||||
line = codecs.escape_decode(line)[0]
|
|
||||||
|
|
||||||
present(module, dest, params['regexp'], line,
|
present(module, dest, params['regexp'], line,
|
||||||
ins_aft, ins_bef, create, backup, backrefs)
|
ins_aft, ins_bef, create, backup, backrefs)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user