]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool gpo: better entities check copes with new lines
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 14 Mar 2025 04:45:18 +0000 (17:45 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 25 Mar 2025 04:20:45 +0000 (04:20 +0000)
Per https://www.w3.org/TR/xml/#sec-entity-decl (and MS references)
there is always some whitespace between '<!ENTITY' and the name, and
between the name and whatever is next. Also, it is valid XML to have
newlines inside entity declarations, like this:

<!ENTITY
    bubble
      "*S-1-5-113"
      >

We used to create such files, so we should allow them.

There is a kind of entity that has '%' before the name, and there are
non-ascii names, which we continue not to support.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
python/samba/netcmd/gpo.py

index 27293ecb4ee68defe737af0073cfffd6db3a5a7b..ada5f142a6f8d9f5a900f9a4f6288562cc6041ca 100644 (file)
@@ -1654,8 +1654,8 @@ class cmd_restore(cmd_create):
                 entities_content = entities_file.read()
 
                 # Do a basic regex test of the entities file format
-                if re.match(r'(\s*<!ENTITY\s*[a-zA-Z0-9_]+\s*.*?>)+\s*\Z',
-                            entities_content, flags=re.MULTILINE) is None:
+                if re.match(r'(\s*<!ENTITY\s+[a-zA-Z0-9_]+\s+.*?>)+\s*\Z',
+                            entities_content, flags=re.MULTILINE|re.DOTALL) is None:
                     raise CommandError("Entities file does not appear to "
                                        "conform to format\n"
                                        'e.g. <!ENTITY entity "value">')