Skip to content

Commit 2076211

Browse files
authored
Merge pull request #1695 from YUK1PEDIA/fix-escaping-issue
fix: [supervisord] environment section does not properly escape %%
2 parents 16912f0 + 18438c5 commit 2076211

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

supervisor/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def get(opt, default, **kwargs):
657657
section.nocleanup = boolean(get('nocleanup', 'false'))
658658
section.strip_ansi = boolean(get('strip_ansi', 'false'))
659659

660-
environ_str = get('environment', '')
660+
environ_str = get('environment', '', do_expand=False)
661661
environ_str = expand(environ_str, expansions, 'environment')
662662
section.environment = dict_of_key_value_pairs(environ_str)
663663

supervisor/tests/test_options.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,6 +3409,18 @@ def test_daemonize_notifies_poller_before_and_after_fork(self):
34093409
instance.poller.before_daemonize.assert_called_once_with()
34103410
instance.poller.after_daemonize.assert_called_once_with()
34113411

3412+
def test_options_environment_of_supervisord_with_escaped_chars(self):
3413+
text = lstrip("""
3414+
[supervisord]
3415+
environment=VAR_WITH_P="some_value_%%_end"
3416+
""")
3417+
3418+
instance = self._makeOne()
3419+
instance.configfile = StringIO(text)
3420+
instance.realize(args=[])
3421+
options = instance.configroot.supervisord
3422+
self.assertEqual(options.environment, dict(VAR_WITH_P="some_value_%_end"))
3423+
34123424
class ProcessConfigTests(unittest.TestCase):
34133425
def _getTargetClass(self):
34143426
from supervisor.options import ProcessConfig

0 commit comments

Comments
 (0)