File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 9
9
the ``[supervisorctl] `` section or ``[ctlplugin:x] `` sections to be in
10
10
included files. Patch by François Granade.
11
11
12
+ - Parsing ``environment= `` has been improved to allow escaped quotes
13
+ inside quotes and quoted empty values. Patch by Stefan Friesel.
14
+
12
15
4.2.5 (2022-12-23)
13
16
------------------
14
17
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def dict_of_key_value_pairs(arg):
68
68
""" parse KEY=val,KEY2=val2 into {'KEY':'val', 'KEY2':'val2'}
69
69
Quotes can be used to allow commas in the value
70
70
"""
71
- lexer = shlex .shlex (str (arg ))
71
+ lexer = shlex .shlex (str (arg ), posix = True )
72
72
lexer .wordchars += '/.+-():'
73
73
74
74
tokens = list (lexer )
@@ -81,7 +81,7 @@ def dict_of_key_value_pairs(arg):
81
81
if len (k_eq_v ) != 3 or k_eq_v [1 ] != '=' :
82
82
raise ValueError (
83
83
"Unexpected end of key/value pairs in value '%s'" % arg )
84
- D [k_eq_v [0 ]] = k_eq_v [2 ]. strip ( ' \' "' )
84
+ D [k_eq_v [0 ]] = k_eq_v [2 ]
85
85
i += 4
86
86
return D
87
87
Original file line number Diff line number Diff line change @@ -164,6 +164,11 @@ def test_handles_newlines_inside_quotes(self):
164
164
expected = {'foo' : 'a\n b\n c' }
165
165
self .assertEqual (actual , expected )
166
166
167
+ def test_handles_quotes_inside_quotes (self ):
168
+ actual = datatypes .dict_of_key_value_pairs ('foo="\' \\ ""' )
169
+ expected = {'foo' : '\' "' }
170
+ self .assertEqual (actual , expected )
171
+
167
172
def test_handles_empty_inside_quotes (self ):
168
173
actual = datatypes .dict_of_key_value_pairs ('foo=""' )
169
174
expected = {'foo' : '' }
You can’t perform that action at this time.
0 commit comments