return nil
end,
['description'] = [[Get MIME or SMTP from (e.g. `from('smtp')` or `from('mime')`,
-uses any type by default)]],
+uses any type by default); add `orig` (e.g. `from('mime', 'orig')`) to get the
+address as it was seen in the message, before any rewrite (e.g. by the aliases module)]],
},
['rcpts'] = {
['get_value'] = function(task, args)
return nil
end,
['description'] = [[Get MIME or SMTP rcpts (e.g. `rcpts('smtp')` or `rcpts('mime')`,
-uses any type by default)]],
+uses any type by default); add `orig` (e.g. `rcpts('mime', 'orig')`) to get the
+addresses as they were seen in the message, before any rewrite (e.g. by the aliases module)]],
},
-- Get country (ASN module must be executed first)
['country'] = {
Scan File ${MESSAGE}
... Settings={symbols_enabled = [RSPAMD_TEXT_SELECTOR]}
Expect Symbol RSPAMD_TEXT_SELECTOR
+
+From selector orig flavour
+ [Documentation] from('mime', 'orig') must return the wire From through the
+ ... selector pipeline even after a task:set_from rewrite
+ Scan File ${RSPAMD_TESTDIR}/messages/from/from_dn.eml
+ ... Rewrite-Mime-From=yes
+ ... Settings={symbols_enabled = [REWRITE_MIME_FROM, SELECTOR_FROM_ORIG]}
+ Expect Symbol With Exact Options SELECTOR_FROM_ORIG forged@forged.example.net|user@example.org
re = 'some_rspamd_text_re=/^hello$/{selector}',
score = 1,
}
+
+-- The 'orig' flavour must be reachable through selectors and return the
+-- address as it was seen in the message, before any task:set_from rewrite
+local selector_from = lua_selectors.create_selector_closure(
+ rspamd_config, "from('mime'):addr", '')
+local selector_from_orig = lua_selectors.create_selector_closure(
+ rspamd_config, "from('mime', 'orig'):addr", '')
+
+rspamd_config:register_symbol({
+ name = 'SELECTOR_FROM_ORIG',
+ score = 1.0,
+ callback = function(task)
+ local cur = selector_from(task)
+ local orig = selector_from_orig(task)
+ return true, string.format('%s|%s', cur or 'nil', orig or 'nil')
+ end
+})