[PATCH] parsemail: ignore html part of multi-part comments

Stephen Finucane stephen at that.guru
Mon Jun 25 05:36:21 AEST 2018


On Wed, 2018-06-20 at 14:21 +0200, Yuri Volchkov wrote:
> Currently an html-protection present only for patch-emails. If a
> multi-part comment-email arrives, it messes up patchwork. In my case,
> the symptom was a non intended 'Signed-off-by' in the downloaded
> patches, with html-like junk.
> 
> This patch makes parsemail skip all parts of comment which are not
> text/plain.
> 
> Of course, this will drop html-only emails completely. But they can
> not be parsed anyways.

Looks good to me. I've applied this to both master and stable/2.1 along
with a patch to test things. Thanks for the contribution!

Stephen

> Signed-off-by: Yuri Volchkov <yuri.volchkov at gmail.com>
> ---
>  patchwork/parser.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/patchwork/parser.py b/patchwork/parser.py
> index 8f9af81..b1fb7b9 100644
> --- a/patchwork/parser.py
> +++ b/patchwork/parser.py
> @@ -576,9 +576,11 @@ def find_comment_content(mail):
>      """Extract content from a mail."""
>      commentbuf = ''
>  
> -    for payload, _ in _find_content(mail):
> +    for payload, subtype in _find_content(mail):
>          if not payload:
>              continue
> +        if subtype != 'plain':
> +            continue
>  
>          commentbuf += payload.strip() + '\n'
>  



More information about the Patchwork mailing list