From ab0d1951968e870f7e103f96ef3517ad88b787bd Mon Sep 17 00:00:00 2001 From: evilhero Date: Sat, 25 Nov 2017 12:14:06 -0500 Subject: [PATCH] FIX:(#1785) Fix for passwords containing a % character causing interpolation problems due to the config parser --- mylar/config.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mylar/config.py b/mylar/config.py index 0cc451b0..0a3078a9 100644 --- a/mylar/config.py +++ b/mylar/config.py @@ -400,11 +400,17 @@ class Config(object): setattr(self, k, value) + try: + #make sure interpolation isn't being used, so we can just escape the % character + if v[0] == str: + value = value.replace('%', '%%') + except Exception as e: + pass + #just to ensure defaults are properly set... if any([value is None, value == 'None']): value = v[0](v[2]) - if all([self.MINIMAL_INI is True, str(value) != str(v[2])]) or self.MINIMAL_INI is False: try: config.add_section(v[1]) @@ -580,8 +586,12 @@ class Config(object): if any([value is None, value == ""]): value = definition_type(default) if config.has_section(section) and (all([self.MINIMAL_INI is True, definition_type(value) != definition_type(default)]) or self.MINIMAL_INI is False): + try: + if definition_type == str: + value = value.replace('%', '%%') + except Exception as e: + pass config.set(section, ini_key, str(value)) - else: config.set(section, ini_key, str(self.MINIMAL_INI))