From d5d96bed02fab78386fad908e4dd18c1adcd4795 Mon Sep 17 00:00:00 2001 From: Gabriel Nagy Date: Tue, 24 Oct 2023 12:47:02 +0300 Subject: [PATCH] gp_pol: Allow null data for REG_MULTI_SZ The parser is able to convert data from binary to XML (it generates an empty tag) but not the other way around. This is a common occurrence for empty multitext fields. Signed-off-by: Gabriel Nagy Reviewed-by: Andrew Bartlett Reviewed-by: David Mulder --- python/samba/gp_parse/gp_pol.py | 6 +++++- selftest/knownfail.d/gpo | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 selftest/knownfail.d/gpo diff --git a/python/samba/gp_parse/gp_pol.py b/python/samba/gp_parse/gp_pol.py index 8a3d5f58ec1..1d5f348176b 100644 --- a/python/samba/gp_parse/gp_pol.py +++ b/python/samba/gp_parse/gp_pol.py @@ -77,7 +77,11 @@ class GPPolParser(GPParser): if misc.REG_MULTI_SZ == entry_type: values = [x.text for x in e.findall('Value')] - entry.data = (u'\x00'.join(values) + u'\x00\x00').encode('utf-16le') + if values == [None]: + data = u'\x00' + else: + data = u'\x00'.join(values) + u'\x00\x00' + entry.data = data.encode('utf-16le') elif (misc.REG_NONE == entry_type): pass elif (misc.REG_SZ == entry_type or diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo deleted file mode 100644 index 55f943f4341..00000000000 --- a/selftest/knownfail.d/gpo +++ /dev/null @@ -1 +0,0 @@ -^samba.tests.gpo.samba.tests.gpo.GPOTests.test_parser_roundtrip_empty_multi_sz -- 2.47.3