Merge lp:~msapiro/mailman/bug_949924 into lp:mailman
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Barry Warsaw | ||||
Approved revision: | 7124 | ||||
Merged at revision: | 7142 | ||||
Proposed branch: | lp:~msapiro/mailman/bug_949924 | ||||
Merge into: | lp:mailman | ||||
Diff against target: |
112 lines (+79/-1) 3 files modified
src/mailman/docs/NEWS.rst (+2/-0) src/mailman/rules/approved.py (+3/-1) src/mailman/rules/tests/test_approved.py (+74/-0) |
||||
To merge this branch: | bzr merge lp:~msapiro/mailman/bug_949924 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Barry Warsaw | Approve | ||
Review via email: mp+97787@code.launchpad.net |
Description of the change
This branch fixes mailman/
It is a very minimal fix. The issue is if we're looking for a Approve(d): pseudo header in the first text/plain part, and this part contains non-ascii characters, the statement "if ':' in line:" does an implicit decode to unicode which throws an exception on the non-ascii character. This apparently doesn't fail in 2.1 because 2.1 does line.find(':') instead. I fixed it by doing an explicit decode in the charset of the part with 'replace'.
I also changed a <> to != for Python 3
I didn't make any tests or NEWS entry. I did locally modify mailman/
=== modified file 'src/mailman/
--- src/mailman/
+++ src/mailman/
@@ -150,20 +150,25 @@
>>> msg = message_
... From: <email address hidden>
+ ... MIME-Version: 1.0
+ ... Content-Type: text/plain; charset=
+ ... Content-
...
... Approved: abcxyz
... An important message.
+ ... A funny character =E4.
... """)
>>> rule.check(mlist, msg, {})
True
>>> print msg.as_string()
From: <email address hidden>
- Content-
+ Content-
MIME-Version: 1.0
- Content-Type: text/plain; charset="us-ascii"
+ Content-Type: text/plain; charset=
<BLANKLINE>
An important message.
+ A funny character =E4.
<BLANKLINE>
As before, a mismatch in the pseudo-header does not approve the message, but
This does actually throw an exception without the fix and passes with it, but this is not the right place for this test, and there is no existing unit test module, and I wanted to expose this fix before taking the time to learn to construct a proper unit test.
There is also an extension to Approve.py in 2.1 which will reject the post if the (X-)Approve(d): header can't be found in an HTML part, but can be found after stripping out HTML tags. See comments #6 - #8 at LP: #266220 for more on this. I thought it was too much to try to incorporate that with this fix.
I added a unit test. It probably needs some cleanup as I still don't really understand the unittest framework.
I renamed the approve.rst doctest to approved.rst for consistency.
I added a bug fix note to NEWS.