]> git.ipfire.org Git - thirdparty/patchwork.git/commit
parser: Fix parsing of pull request emails with CRLF line endings on Python 2
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Mon, 8 Jan 2018 07:46:45 +0000 (18:46 +1100)
committerDaniel Axtens <dja@axtens.net>
Mon, 29 Jan 2018 09:48:02 +0000 (20:48 +1100)
commit3f46c99a403d1ec2cc86d67c7c88c61e5584403b
tree6a0b97c359bf8a097c109c1d02f5d3f934a7e00f
parentbe1dbab99bf51b9e700102a676ed96fa7c462912
parser: Fix parsing of pull request emails with CRLF line endings on Python 2

When using Python 2, an incoming email that uses CRLF line endings won't
have the line endings converted by the email parser. This means that the
regex to detect pull request emails will fail to match.

Clean up the line endings when we extract the email body to fix this. (On
Python 3, the email parser policy fixes this for us at the initial email
parsing stage.)

Add a test pull request mbox with CRLF line endings to ensure we don't
regress.

Closes: #148 ("Parsing pull request emails broken on Python 2")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
[dja: fix up CRLF line endings munged by git-send-email
      renumber test
      re-order lines to put line-ending munging before other processing
      verify CRLF in file
      skip test if py3 for speed]
Signed-off-by: Daniel Axtens <dja@axtens.net>
patchwork/parser.py
patchwork/tests/mail/0018-git-pull-request-crlf-newlines.mbox [new file with mode: 0644]
patchwork/tests/test_parser.py