1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

gpo: Parse GPT.INI with Latin-1

For some reason the French version of RSAT turns accents into ISO-8859-1.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13806

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Garming Sam 2019-02-26 15:35:44 +13:00 committed by Andrew Bartlett
parent 70681d41ac
commit 75cf728398

View File

@ -105,6 +105,17 @@ class GPIniParser(GPParser):
class GPTIniParser(GPIniParser):
encoding = 'utf-8'
def parse(self, contents):
try:
super(GPTIniParser, self).parse(contents)
except UnicodeDecodeError:
# Required dict_type in Python 2.7
self.ini_conf = ConfigParser(dict_type=collections.OrderedDict)
self.ini_conf.optionxform = str
# Fallback to Latin-1 which RSAT appears to use
self.ini_conf.readfp(StringIO(contents.decode('iso-8859-1')))
class GPScriptsIniParser(GPIniParser):
def build_xml_parameter(self, section_xml, section, key_ini, val_ini):