[PATCH 01/10] parser: fix charset 'guessing' algorithm

Andrew Donnellan andrew.donnellan at au1.ibm.com
Wed Jun 28 18:04:47 AEST 2017


Reviewed-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>

On 28/06/17 17:48, Daniel Axtens wrote:
> The charset guessing algorithm doesn't work if it has to guess
> multiple charsets, as it overwrites the payload with None.
>
> Signed-off-by: Daniel Axtens <dja at axtens.net>
> ---
>  patchwork/parser.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/patchwork/parser.py b/patchwork/parser.py
> index 794a5eac2d29..4903aa8237e6 100644
> --- a/patchwork/parser.py
> +++ b/patchwork/parser.py
> @@ -448,10 +448,11 @@ def _find_content(mail):
>
>              for cset in try_charsets:
>                  try:
> -                    payload = six.text_type(payload, cset)
> +                    new_payload = six.text_type(payload, cset)
>                      break
>                  except UnicodeDecodeError:
> -                    payload = None
> +                    new_payload = None
> +            payload = new_payload
>
>              # Could not find a valid decoded payload.  Fail.
>              if payload is None:
>

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com  IBM Australia Limited



More information about the Patchwork mailing list