]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Lua_magic: Fix xml detection
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 13 Aug 2021 13:00:35 +0000 (14:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 13 Aug 2021 13:00:35 +0000 (14:00 +0100)
lualib/lua_magic/heuristics.lua
lualib/lua_magic/types.lua

index d3469e2f9cbf9af3576b7f5173888a01c820539b..2571346b4bf840f97bb7b2f18d1ace03b427c372 100644 (file)
@@ -63,15 +63,15 @@ local zip_patterns = {
 local txt_trie
 local txt_patterns = {
   html = {
-    {[[(?i)\s*<html\b]], 30},
-    {[[(?i)\s*<script\b]], 20}, -- Commonly used by spammers
-    {[[(?i)\s*<\!DOCTYPE HTML\b]], 30},
-    {[[(?i)\s*<body\b]], 20},
-    {[[(?i)\s*<table\b]], 20},
-    {[[(?i)\s*<a\b]], 10},
-    {[[(?i)\s*<p\b]], 10},
-    {[[(?i)\s*<div\b]], 10},
-    {[[(?i)\s*<span\b]], 10},
+    {[[(?i)<html\b]], 32},
+    {[[(?i)<script\b]], 20}, -- Commonly used by spammers
+    {[[(?i)<\!DOCTYPE HTML\b]], 33},
+    {[[(?i)<body\b]], 20},
+    {[[(?i)<table\b]], 20},
+    {[[(?i)<a\b]], 10},
+    {[[(?i)<p\b]], 10},
+    {[[(?i)<div\b]], 10},
+    {[[(?i)<span\b]], 10},
   },
   csv = {
     {[[(?:[-a-zA-Z0-9_]+\s*,){2,}(?:[-a-zA-Z0-9_]+,?[ ]*[\r\n])]], 20}
@@ -82,6 +82,9 @@ local txt_patterns = {
   vcf = {
     {[[^BEGIN:VCARD\r?\n]], 40},
   },
+  xml = {
+    {[[(?i)\s*<\?xml\b.+\?>]], 31},
+  }
 }
 
 -- Used to match pattern index and extension
index 9f64b12a2cceab6472d6a3dbdde17acbe6e2f73e..f082a53e5177a3d8c04d0c8e69c75c68549bbf0c 100644 (file)
@@ -284,6 +284,10 @@ local types = {
     ct = 'image/vnd.dwg',
   },
   -- Text
+  xml = {
+    ct = 'application/xml',
+    type = 'text',
+  },
   txt = {
     type = 'text',
     ct = 'text/plain',