Skip to content

Commit 431b3a1

Browse files
committed
Fix parsing environment= with empty quoted strings
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
1 parent f3ffaf3 commit 431b3a1

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

supervisor/datatypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def dict_of_key_value_pairs(arg):
6565
""" parse KEY=val,KEY2=val2 into {'KEY':'val', 'KEY2':'val2'}
6666
Quotes can be used to allow commas in the value
6767
"""
68-
lexer = shlex.shlex(arg)
68+
lexer = shlex.shlex(str(arg))
6969
lexer.wordchars += '/.+-():'
7070

7171
tokens = list(lexer)

supervisor/tests/test_datatypes.py

-5
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@ def test_handles_newlines_inside_quotes(self):
162162
expected = {'foo': 'a\nb\nc'}
163163
self.assertEqual(actual, expected)
164164

165-
def test_handles_quotes_inside_quotes(self):
166-
actual = datatypes.dict_of_key_value_pairs('foo="\'\\""')
167-
expected = {'foo': '\'"'}
168-
self.assertEqual(actual, expected)
169-
170165
def test_handles_empty_inside_quotes(self):
171166
actual = datatypes.dict_of_key_value_pairs('foo=""')
172167
expected = {'foo': ''}

0 commit comments

Comments
 (0)