gp_pol: Allow null data for REG_MULTI_SZ
authorGabriel Nagy <gabriel.nagy@canonical.com>
Tue, 24 Oct 2023 09:47:02 +0000 (12:47 +0300)
committerDavid Mulder <dmulder@samba.org>
Fri, 27 Oct 2023 13:47:31 +0000 (13:47 +0000)
The parser is able to convert data from binary to XML (it generates an
empty <Value> tag) but not the other way around. This is a common
occurrence for empty multitext fields.

Signed-off-by: Gabriel Nagy <gabriel.nagy@canonical.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
python/samba/gp_parse/gp_pol.py
selftest/knownfail.d/gpo [deleted file]

index 8a3d5f58ec17569f60fadf61c8a67e58491fd86f..1d5f348176b027c15727a47be45394efbd52b2a2 100644 (file)
@@ -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 (file)
index 55f943f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba.tests.gpo.samba.tests.gpo.GPOTests.test_parser_roundtrip_empty_multi_sz