]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Skip bitcoin address check for very long words 3894/head
authorAnton Yuzhaninov <citrin+git@citrin.ru>
Fri, 17 Sep 2021 08:46:32 +0000 (09:46 +0100)
committerAnton Yuzhaninov <citrin+git@citrin.ru>
Fri, 17 Sep 2021 08:46:32 +0000 (09:46 +0100)
Exclude very long words (which can be extracted e. g. from some text
attachments) from bitcoin address check to avoid excessive resource
usage.

rules/bitcoin.lua

index 3cf97fcbee022f560e1d6027c443d02ec1f570a6..731bf46720999da43880dc31a5632d59017fba79 100644 (file)
@@ -184,7 +184,8 @@ config.regexp['BITCOIN_ADDR'] = {
   re = string.format('(%s) + (%s) > 0', normal_wallet_re, btc_bleach_re),
   re_conditions = {
     [normal_wallet_re] = function(task, txt, s, e)
-      if e - s <= 2 then
+      local len = e - s
+      if len <= 2 or len > 1024 then
         return false
       end
 
@@ -205,7 +206,8 @@ config.regexp['BITCOIN_ADDR'] = {
       end
     end,
     [btc_bleach_re] = function(task, txt, s, e)
-      if e - s <= 2 then
+      local len = e - s
+      if len <= 2 or len > 1024 then
         return false
       end