Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
73f52cb8 by Mark Sapiro at 2021-08-04T19:05:23-07:00
Don't remove trailing spaces from header/footer templates.

- - - - -
4721fa27 by Mark Sapiro at 2021-08-05T03:07:17+00:00
Merge branch 'decorate' into 'master'

Don't remove trailing spaces from header/footer templates.

Closes #932

See merge request mailman/mailman!900
- - - - -


3 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/handlers/decorate.py
- src/mailman/handlers/tests/test_decorate.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -96,6 +96,8 @@ Bugs
   to the list's preferred language.  (Closes #930)
 * The ``mailman syncmembers`` command now catches and reports a
   ``SubscriptionPendingError``.  (Closes #929)
+* Trailing spaces are no longer removed from header and footer templates.
+  (Closes #932)
 
 Command line
 ------------


=====================================
src/mailman/handlers/decorate.py
=====================================
@@ -248,7 +248,7 @@ def decorate_template(mlist, template, extradict=None):
         substitutions.update(extradict)
     text = expand(template, mlist, substitutions)
     # Turn any \r\n line endings into just \n
-    return re.sub(r' *\r?\n', r'\n', text)
+    return re.sub(r'\r\n', r'\n', text)
 
 
 @public


=====================================
src/mailman/handlers/tests/test_decorate.py
=====================================
@@ -131,6 +131,18 @@ This is a test message.
         self.assertIn('http://example.com/link_to_message',
                       self._msg.as_string())
 
+    def test_trailing_space_not_removed(self):
+        site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
+        os.makedirs(site_dir)
+        footer_path = os.path.join(site_dir, 'myfooter.txt')
+        with open(footer_path, 'w', encoding='utf-8') as fp:
+            print('-- \r\nMy sig', file=fp)
+        getUtility(ITemplateManager).set(
+            'list:member:regular:footer', None, 'mailman:///myfooter.txt')
+        self._mlist.preferred_language = 'en'
+        decorate.process(self._mlist, self._msg, {})
+        self.assertTrue(self._msg.as_string().endswith('-- \nMy sig\n'))
+
     def test_decorate_member_as_address(self):
         site_dir = os.path.join(config.TEMPLATE_DIR, 'site', 'en')
         os.makedirs(site_dir)



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/cf58b209170f57377d51bfbf877a11ab017520d8...4721fa2724fb049b77e9da4189ca0e51cbcd7847

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/cf58b209170f57377d51bfbf877a11ab017520d8...4721fa2724fb049b77e9da4189ca0e51cbcd7847
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to