[Rspamd-Users] Not working: task:modify_header(name, mods)

lutz.niederer at gmx.net lutz.niederer at gmx.net
Thu Aug 25 04:17:32 UTC 2022


This way it works:

local lua_mime = require "lua_mime"
lua_mime.modify_headers (task, {remove = { ['X-DODO'] = 0, ['X-DODO1'] = 0 }, add = { ['X-DODO'] = { value = 'VALUE', order = 1 }, ['X-DODO1'] = { value = 'VALUE', order = 1 } }})

Why?


> Gesendet: Mittwoch, 24. August 2022 um 18:21 Uhr
> Von: lutz.niederer at gmx.net
> An: users at lists.rspamd.com
> Betreff: Re: [Rspamd-Users] Not working: task:modify_header(name, mods)
>
> > Gesendet: Mittwoch, 24. August 2022 um 17:53 Uhr
> > Von: "G.W. Haywood via Users" <users at lists.rspamd.com>
> >
> > On Wed, 24 Aug 2022, lutz.niederer at gmx.net wrote:
> >
> > > I have tried everything with task:modify_header(name, mods).  Nothing works.
> > > task:modify_header( 'X-ENTRY', { add = {0, "VALUE"}, remove = {0} } )
> > > This seems to me the closest thing that should work...
> >
> > I haven't used any of this personally, but that doesn't match my
> > reading of the documentation:
> >
> > https://rspamd.com/doc/lua/rspamd_task.html#m3b1f8
> >
> > > Could someone please show me how this would be called correctly?
> >
> > Based on my reading of the documentation linked above, try putting
> > quotes around "add" and "remove" ?
>
> If you place quotes around add & remove you get an error from rspamadm configtest.
> From the documentation add is { { order, value }, { order, value } } and remove is { order, order, order } which does not make sense to me if we are talking about one header.
>
> >
> > > Otherwise I believe that there may be a bug.
> >
> > With something like this it's much more likely to be the user's
> > misunderstanding than to be a fault in the software.  It is however a
> > little unfortunate that the rendering of the documentation on the
> > rspamd Website leaves much to be desired from the formatting POV.
>
> I believe that, too.  But I am not sure.  I don't know how many people use LUA inline code in config files.  From the search with google I found that there are nearly no references to that function.  ...  and not only from the formatting POV.  I am missing much of the glue and a "big picture" of symbols etc, who sets what when and who does what with them when.  I ended up with trial and error learning in an amount that I normally don't want with mail filtering.
>
> >
> > Incidentally you should _append_ any header like X-ENTRY so I think you
> > would want {-1, "VALUE"} instead of {0, "VALUE"} in the 'mods' table.
> > In general I'd be cautious about removing headers.
>
> Maybe, but currently the function doesn't do anything.  With debug mode you don't see any errors or hints that the function is ever executed.
>
> Cheers!
> -lutzn
>
> --
> Users mailing list
> Users at lists.rspamd.com
> https://lists.rspamd.com/mailman/listinfo/users
>


More information about the Users mailing list