]> 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)
committerJule Anger <janger@samba.org>
Thu, 17 Apr 2025 11:31:14 +0000 (11:31 +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>
(cherry picked from commit 6107656ebc8d092b2c1907940b2486ab0265aad9)

python/samba/netcmd/gpo.py

index 12fc2c6c40922bf88b7f78dd168694886bdad2ce..b5d18b59e2f11fd891292fa1685910e5f463f90f 100644 (file)
@@ -1653,8 +1653,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">')