[Remail] [RFC/RFT V2 patch 2/2] remail: Provide a less convoluted From: header mangling

Konstantin Ryabitsev konstantin at linuxfoundation.org
Fri Jun 16 21:31:13 CEST 2023


On Tue, Jun 13, 2023 at 09:43:23PM +0200, Thomas Gleixner wrote:
> --- a/Documentation/man5/remail.config.rst
> +++ b/Documentation/man5/remail.config.rst
> @@ -264,6 +264,7 @@ Base configuration items
>        moderated:          True
>        attach_sender_info: False
>        set_original_from:  False
> +      mangle_from_v2:     False

I'm generally opposed to making this configurable -- let's just make this
change the new behaviour. It's not the kernel and we don't need to remain 100%
compatible with existing installs, especially when we know everyone running
remail by name (probably).

Everywhere I've seen that does From: mangling, it's always "Firstname Lastname
via Mailing List", so I think you wouldn't hurt anyone's feelings if you 

> +def get_name_and_email_addr(addr):
> +    try:
> +        name, addr = addr.split('<')
> +    except:
> +        name = ''
> +    return name.strip(), addr.lstrip('<').rstrip('>')

Believe it or not, there are ways in which this would fail. I recommend using
email.utils.parseaddr(). E.g.:

    In [1]: import email.utils as eu
    In [2]: eu.parseaddr('"Foo <Angles> Bar" <foo at bar.baz>')
    Out[2]: ('Foo <Angles> Bar', 'foo at bar.baz')

-K


More information about the Remail mailing list