diff options
author | Garming Sam <garming@catalyst.net.nz> | 2019-02-26 15:35:44 +1300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-03-12 00:42:20 +0000 |
commit | 75cf728398421435186559306b0962c70f333c6e (patch) | |
tree | 592a852b08f2ab2dc8abad981b7c21fcfa294330 /python/samba | |
parent | 70681d41ac2fb6d401157952077aaa8b8f800a2e (diff) | |
download | samba-75cf728398421435186559306b0962c70f333c6e.tar.gz |
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>
Diffstat (limited to 'python/samba')
-rw-r--r-- | python/samba/gp_parse/gp_ini.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/python/samba/gp_parse/gp_ini.py b/python/samba/gp_parse/gp_ini.py index 58aee88a1e1..590b71b9a6c 100644 --- a/python/samba/gp_parse/gp_ini.py +++ b/python/samba/gp_parse/gp_ini.py @@ -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): |