]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix XML prolog detection in lua_magic
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 25 Sep 2025 09:40:22 +0000 (10:40 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 25 Sep 2025 09:40:22 +0000 (10:40 +0100)
lualib/lua_magic/patterns.lua

index b51deab7f61d809267815426765008a13c079940..df524f177cc8984df7689c7fdcd7b9483c15c77c 100644 (file)
@@ -448,14 +448,24 @@ local patterns = {
       {
         -- Case-insensitive <svg ...> in the first chunk
         string = [[(?i)<svg\b]],
-        position = { '>=', 0 },
+        position = { '<=', 4096 },
+        weight = 40,
+      },
+      {
+        -- Case-insensitive <!DOCTYPE svg ...> within the first 4KiB
+        string = [[(?i)<!doctype\s+svg]],
+        position = { '<=', 4096 },
         weight = 40,
       },
+    }
+  },
+  xml = {
+    matches = {
       {
-        -- XML prolog hints
-        string = [[<\?xml\b]],
+        -- XML prolog
+        string = [[<\?xml\b.+\?>]],
         position = { '>=', 0 },
-        weight = 20,
+        weight = 30,
       },
     }
   },