[PATCH] parser: Ignore CFWS in In-Reply-To, References headers

DJ Delorie dj at redhat.com
Sat May 7 05:31:22 AEST 2022


Stephen Finucane <stephen at that.guru> writes:
> diff --git patchwork/parser.py patchwork/parser.py
> index e6e1a7fb..17cc2325 100644
> --- patchwork/parser.py
> +++ patchwork/parser.py
> @@ -31,6 +31,7 @@ from patchwork.models import SeriesReference
>  from patchwork.models import State
>  
>  
> +_msgid_re = re.compile(r'<[^>]+>')

Ok; a msgid is <something> and we don't support <> (empty) msgid

>      if 'In-Reply-To' in mail:
>          for in_reply_to in mail.get_all('In-Reply-To'):
> -            r = clean_header(in_reply_to)
> -            if r:
> -                refs.append(r)
> +            ref = _msgid_re.search(clean_header(in_reply_to))
> +            if ref:
> +                refs.append(ref.group(0))

Instead of appending the header as-is, we extract all <*> patterns, OK.
Would have the same effect if the string only had a msgid in it.

>      if 'References' in mail:
>          for references_header in mail.get_all('References'):
> -            h = clean_header(references_header)
> -            if not h:
> -                continue
> -            references = h.split()
> +            references = _msgid_re.findall(clean_header(references_header))
>              references.reverse()
>              for ref in references:
> -                ref = ref.strip()
>                  if ref not in refs:
>                      refs.append(ref)

Likewise OK.

> diff --git patchwork/tests/test_parser.py patchwork/tests/test_parser.py

The rest looks all OK to me, without needing line-by-line review.

Thanks!
Reviewed-by: DJ Delorie <dj at redhat.com>



More information about the Patchwork mailing list