Merge pull request #9039 from terminalmage/issue8585

Fix argument parsing for arguments containing pound signs
This commit is contained in:
Pedro Algarvio 2013-12-05 03:21:18 -08:00
commit 6caa40bcbe
2 changed files with 16 additions and 0 deletions

View File

@ -195,6 +195,10 @@ def yamlify_arg(arg):
try:
original_arg = str(arg)
if isinstance(arg, string_types):
if '#' in arg:
# Don't yamlify this argument or the '#' and everything after
# it will be interpreted as a comment.
return arg
if '\n' not in arg:
arg = yaml.safe_load(arg)
if isinstance(arg, dict):

View File

@ -41,6 +41,18 @@ class ArgumentTestCase(integration.ModuleCase):
'baz'
)
def test_argument_containing_pound_sign(self):
'''
Tests the argument parsing to ensure that a CLI argument with a pound
sign doesn't have the pound sign interpreted as a comment and removed.
See https://github.com/saltstack/salt/issues/8585 for more info.
'''
arg = 'foo bar #baz'
self.assertEqual(
self.run_function('test.echo', [arg]),
arg
)
if __name__ == '__main__':
from integration import run_tests