Re: [PATCH v6 1/2] parsemail: Convert to a management command

2016-09-21 Thread Thomas Monjalon
Hi,

2016-09-20 00:08, Stephen Finucane:
> On 20 Sep 01:22, Daniel Axtens wrote:
> > So, umm, I went ahead and had a crack at this.
> > 
> > It turns out this is hideously difficult to get right. But this plus my
> > other patch to fix Thomas' problem should have things working on Py2 and
> > Py3 with this series.

Thanks for taking care.

[...]
> I don't have the offending patch on hand, but isn't the issue with the
> headers. If so, would something like the below do (I haven't tested
> it - there could be typos).
[...]

Please would it be possible to fix this bug in the stable branch also?
Thanks a lot
___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


Re: [PATCH] parser: leniently parse headers as UTF-8

2016-09-21 Thread Daniel Axtens
Hi,

Stephen's suggested patch is a bit better here, so drop this for
now. v2, tests, etc. to come.

Regards,
Daniel

> If there is a non-ascii character in a header, parsing fails,
> even on Py27.
>
> Try to decode headers as UTF-8, but if that fails, replace the
> offending bytes with a character marking that decoding failed.
> See:
> https://docs.python.org/3/howto/unicode.html#python-s-unicode-support
>
> This is handy for mails with malformed headers containing weird
> bytes.
>
> Reported-by: Thomas Monjalon 
> Signed-off-by: Daniel Axtens 
>
> ---
>
> Many thanks to Thomas for his help debugging this.
>
> Happy to bikeshed whether we want 'replace' or perhaps
> 'backslashreplace'. Not keen on 'ignore'; it has an interesting
> security history - but willing to entertain convincing arguments.
>
> This should probably go to a stable branch too. We'll need to start
> some discussion about how to handle bug fixes for people not running
> git mainline (like ozlabs.org and kernel.org).
>
> Tests to prevent this recurring to come. Python 3 patches to come
> also.
> ---
>  patchwork/parser.py | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/patchwork/parser.py b/patchwork/parser.py
> index 1805df8cda7f..d3f55634f530 100644
> --- a/patchwork/parser.py
> +++ b/patchwork/parser.py
> @@ -157,6 +157,7 @@ def find_date(mail):
>  def find_headers(mail):
>  return reduce(operator.__concat__,
>['%s: %s\n' % (k, Header(v, header_name=k,
> +   charset='utf-8', errors='replace',
> continuation_ws='\t').encode())
> for (k, v) in list(mail.items())])
>  
> -- 
> 2.7.4
___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork