[Rspamd-Users] How to regex-match multiline

Tino Hendricks t.hendricks at interpool.de
Sat Aug 2 11:47:15 UTC 2025


Dear list,

trying to match spam containing HTML body

    <p>some words</p>
        </div>
    </div>
</body>
</html>

with multimap 

KNOWN_SPAM_BODY {
  type = "content";
  filter = "body";
  map = "${LOCAL_CONFDIR}/local.d/known_spam_body.map";
  prefilter = false;
  action = "add header";
  regexp = true;
  score = 2.0;
}

and the map containing

/ +<p>.*<\/p>
        <\/div>
    <\/div>
<\/body>
<\/html>/m

Unfortunately It matches every occurrence of "        </div>“ or "    </div>“.

After re-consulting https://docs.rspamd.com/modules/regexp/#regular-expressions and  reading
> m - multi-line regular expression - this flag causes the string to be treated as multiple lines. This means that the ^and $ symbols match the start and end of each line within the string, rather than just the start and end of the first and last lines.


I changed it to

/^ +<p>.*<\/p>$
^        <\/div>$
^    <\/div>$
^<\/body>$
^<\/html>$/m

which results in an error.
What’s the correct way to do it?

Thank you very much!

Tino


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4401 bytes
Desc: not available
URL: <https://lists.rspamd.com/pipermail/users/attachments/20250802/b0dc2c32/attachment.bin>


More information about the Users mailing list