Merge lp:~cjwatson/launchpad/code-review-mail-encoding into lp:launchpad

Proposed by Colin Watson on 2018-08-17
Status: Merged
Merged at revision: 18754
Proposed branch: lp:~cjwatson/launchpad/code-review-mail-encoding
Merge into: lp:launchpad
Diff against target: 35 lines (+4/-3)
2 files modified
lib/lp/code/mail/codereviewcomment.py (+2/-1)
lib/lp/code/mail/tests/test_codereviewcomment.py (+2/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/code-review-mail-encoding
Reviewer Review Type Date Requested Status
William Grant code 2018-08-17 Approve on 2018-08-19
Review via email: mp+353326@code.launchpad.net

Commit message

Fix crash when emailing inline comments on a diff with non-ASCII characters in hunk headers.

Description of the change

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/mail/codereviewcomment.py'
2--- lib/lp/code/mail/codereviewcomment.py 2015-08-23 22:53:55 +0000
3+++ lib/lp/code/mail/codereviewcomment.py 2018-08-17 12:58:38 +0000
4@@ -236,7 +236,8 @@
5
6 # add context line (hunk header)
7 line_count += 1 # inc hunk context line
8- hunk_lines.append(u'> %s' % hunk.get_header().rstrip('\n'))
9+ hunk_lines.append(u'> %s' % hunk.get_header().rstrip('\n').decode(
10+ 'utf-8', 'replace'))
11
12 # comment for context line (hunk header)
13 comment = comments.get(str(line_count))
14
15=== modified file 'lib/lp/code/mail/tests/test_codereviewcomment.py'
16--- lib/lp/code/mail/tests/test_codereviewcomment.py 2015-10-27 01:13:12 +0000
17+++ lib/lp/code/mail/tests/test_codereviewcomment.py 2018-08-17 12:58:38 +0000
18@@ -427,7 +427,7 @@
19 "=== modified file 'foo/bar/bar.py'\n"
20 "--- bar.py\t2009-08-26 15:53:34.000000000 -0400\n"
21 "+++ bar.py\t1969-12-31 19:00:00.000000000 -0500\n"
22- "@@ -1,3 +0,0 @@\n"
23+ "@@ -1,3 +0,0 @@ msgstr \"\xc3\xa5\"\n"
24 "-\xc3\xa5\n"
25 "-b\n"
26 "-c\n"
27@@ -705,7 +705,7 @@
28 '',
29 'Foo',
30 '',
31- '> @@ -1,3 +0,0 @@',
32+ u'> @@ -1,3 +0,0 @@ msgstr "\xe5"',
33 '',
34 'Bar',
35 ''],