summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2012-04-04 15:24:18 -0600
committerBarry Warsaw2012-04-04 15:24:18 -0600
commit53633149a247243efe830d7175906dc204423f41 (patch)
treed36c80c19c26c21a19c988d850d15dbd6a9961d9 /src
parent2c4779c884d2bb09bed6838b7b5cd938d5755f2e (diff)
parentd695a5f65c44be347d007a923874f8cfd836b9de (diff)
downloadmailman-53633149a247243efe830d7175906dc204423f41.tar.gz
mailman-53633149a247243efe830d7175906dc204423f41.tar.zst
mailman-53633149a247243efe830d7175906dc204423f41.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/docs/NEWS.rst5
-rw-r--r--src/mailman/rules/approved.py4
-rw-r--r--src/mailman/rules/docs/approved.rst (renamed from src/mailman/rules/docs/approve.rst)0
-rw-r--r--src/mailman/rules/tests/__init__.py0
-rw-r--r--src/mailman/rules/tests/test_approved.py63
5 files changed, 71 insertions, 1 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 13bb919c1..71a2d0cdc 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -41,6 +41,11 @@ Documentation
* Some additional documentation on related components such as Postorius and
hyperkitty have been added, given by Stephen J Turnbull.
+Bug fixes
+---------
+ * Fixed a UnicodeError with non-ascii message bodies in the `approved` rule,
+ given by Mark Sapiro. (LP: #949924)
+
3.0 beta 1 -- "The Twilight Zone"
=================================
diff --git a/src/mailman/rules/approved.py b/src/mailman/rules/approved.py
index 8981f9030..927a96ee5 100644
--- a/src/mailman/rules/approved.py
+++ b/src/mailman/rules/approved.py
@@ -73,10 +73,12 @@ class Approved:
break
payload = part.get_payload(decode=True)
if payload is not None:
+ charset = part.get_content_charset('us-ascii')
+ payload = payload.decode(charset, 'replace')
line = ''
lines = payload.splitlines(True)
for lineno, line in enumerate(lines):
- if line.strip() <> '':
+ if line.strip() != '':
break
if ':' in line:
header, value = line.split(':', 1)
diff --git a/src/mailman/rules/docs/approve.rst b/src/mailman/rules/docs/approved.rst
index 3e1206563..3e1206563 100644
--- a/src/mailman/rules/docs/approve.rst
+++ b/src/mailman/rules/docs/approved.rst
diff --git a/src/mailman/rules/tests/__init__.py b/src/mailman/rules/tests/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/mailman/rules/tests/__init__.py
diff --git a/src/mailman/rules/tests/test_approved.py b/src/mailman/rules/tests/test_approved.py
new file mode 100644
index 000000000..8ffe68aa9
--- /dev/null
+++ b/src/mailman/rules/tests/test_approved.py
@@ -0,0 +1,63 @@
+# Copyright (C) 2012 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+"""Test the mime_delete handler."""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ 'TestApproved',
+ ]
+
+
+import unittest
+
+from mailman.app.lifecycle import create_list
+from mailman.rules import approved
+from mailman.testing.helpers import (
+ specialized_message_from_string as mfs)
+from mailman.testing.layers import ConfigLayer
+
+
+
+class TestApproved(unittest.TestCase):
+ """Test the approved handler."""
+
+ layer = ConfigLayer
+
+ def setUp(self):
+ self._mlist = create_list('test@example.com')
+ self._rule = approved.Approved()
+ self._msg = mfs("""\
+From: anne@example.com
+To: test@example.com
+Subject: A Message with non-ascii body
+Message-ID: <ant>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+This is a message body with a non-ascii character =E4
+
+""")
+
+ def test_nonascii_body_missing_header(self):
+ # When the message body contains non-ascii, the rule should not throw
+ # unicode errors. LP: #949924.
+ result = self._rule.check(self._mlist, self._msg, {})
+ self.assertFalse(result)