Skip to content

Commit

Permalink
Fix parsing environment= with empty quoted strings
Browse files Browse the repository at this point in the history
Pull #329 changed shlex to posix mode to fix quotes inside
quotes (#328).  A side effect of this change is that it
broke parsing empty quotes (#873).  This seems to be due
to a bug in shlex (http://bugs.python.org/issue21999).
Since no release version of Supervisor has shipped with
shlex in posix mode to support quotes inside quotes, we're
reverting it to fix support for empty quotes which has
shipped for many Supervisor versions.  Two unit tests
introduced in #329 pass without posix mode, so those tests
have been retained.  A unit test was also added for #873
in the previous commit.

Reopens #328
Partially reverts #329
Fixes #873
Closes #880
  • Loading branch information
mnaberez committed May 26, 2017
1 parent f3ffaf3 commit 431b3a1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion supervisor/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def dict_of_key_value_pairs(arg):
""" parse KEY=val,KEY2=val2 into {'KEY':'val', 'KEY2':'val2'}
Quotes can be used to allow commas in the value
"""
lexer = shlex.shlex(arg)
lexer = shlex.shlex(str(arg))
lexer.wordchars += '/.+-():'

tokens = list(lexer)
Expand Down
5 changes: 0 additions & 5 deletions supervisor/tests/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ def test_handles_newlines_inside_quotes(self):
expected = {'foo': 'a\nb\nc'}
self.assertEqual(actual, expected)

def test_handles_quotes_inside_quotes(self):
actual = datatypes.dict_of_key_value_pairs('foo="\'\\""')
expected = {'foo': '\'"'}
self.assertEqual(actual, expected)

def test_handles_empty_inside_quotes(self):
actual = datatypes.dict_of_key_value_pairs('foo=""')
expected = {'foo': ''}
Expand Down

0 comments on commit 431b3a1

Please sign in to comment.