From 6477bdc6fcc5decee9d986caaf68f20646eb8606 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Mon, 1 Oct 2012 08:30:53 +0200 Subject: [PATCH] Use a regexp to filter out arguments instead pipes.quote is a bit overzealous for what we want to do, quoting ; and other characters that you most likely want to use in your shell invocations. The regexp is the best I could come up with to be able to only replace the parts of the arguments that shouldn't be executed. --- library/command | 23 +++++++++-------------- test/TestRunner.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/library/command b/library/command index 61d78ec5632..1b11257de20 100755 --- a/library/command +++ b/library/command @@ -22,8 +22,8 @@ import subprocess import sys import datetime import traceback +import re import shlex -import pipes import os DOCUMENTATION = ''' @@ -131,7 +131,6 @@ class CommandModule(AnsibleModule): def _load_params(self): ''' read the input and return a dictionary and the arguments string ''' args = MODULE_ARGS - items = shlex.split(args) params = {} params['chdir'] = None params['shell'] = False @@ -139,14 +138,13 @@ class CommandModule(AnsibleModule): args = args.replace("#USE_SHELL", "") params['shell'] = True - check_args = shlex.split(args) - l_args = [] - for x in check_args: - if x.startswith("creates="): + r = re.compile(r'(^|\s)(creates|removes|chdir)=(?P[\'"])?(.*?)(?(quote)(?