1
0
Fork 0
mirror of https://github.com/evilhero/mylar synced 2024-12-23 16:22:45 +00:00

FIX:(#1785) Fix for passwords containing a % character causing interpolation problems due to the config parser

This commit is contained in:
evilhero 2017-11-25 12:14:06 -05:00
parent 6754ad0b8b
commit ab0d195196

View file

@ -400,11 +400,17 @@ class Config(object):
setattr(self, k, value) 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... #just to ensure defaults are properly set...
if any([value is None, value == 'None']): if any([value is None, value == 'None']):
value = v[0](v[2]) value = v[0](v[2])
if all([self.MINIMAL_INI is True, str(value) != str(v[2])]) or self.MINIMAL_INI is False: if all([self.MINIMAL_INI is True, str(value) != str(v[2])]) or self.MINIMAL_INI is False:
try: try:
config.add_section(v[1]) config.add_section(v[1])
@ -580,8 +586,12 @@ class Config(object):
if any([value is None, value == ""]): if any([value is None, value == ""]):
value = definition_type(default) 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): 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)) config.set(section, ini_key, str(value))
else: else:
config.set(section, ini_key, str(self.MINIMAL_INI)) config.set(section, ini_key, str(self.MINIMAL_INI))