# HG changeset patch
# User Thomas Arendsen Hein <thomas@intevation.de>
# Date 1153404286 -7200
# Node ID f77551ea55f743a2d69aa5c1543aafd09d96b838
# Parent  bd54096490d32b4c899bd3f6a41e4df4a028567c
fix double quoted-printable encoding in forgotten password email.
Double encoding was introduced by 50c7a0cc1791.
Discussed on MoinMoinBugs/ResetPasswordEmailImproperlyEncoded.

The problem was caused by a bug in python 2.4.3 and above, which doesn't
QP-encode the message as previous versions do it.

diff -r bd54096490d3 -r f77551ea55f7 MoinMoin/mail/sendmail.py
--- a/MoinMoin/mail/sendmail.py	Wed Jul 19 23:51:45 2006 +0200
+++ b/MoinMoin/mail/sendmail.py	Thu Jul 20 16:04:46 2006 +0200
@@ -74,7 +74,13 @@ def sendmail(request, to, subject, text,
     charset.header_encoding = QP
     charset.body_encoding = QP
     msg.set_charset(charset)
-    msg.set_payload(charset.body_encode(text))
+
+    # work around a bug in python 2.4.3 and above:
+    msg.set_payload('=')
+    if msg.as_string().endswith('='):
+        text = charset.body_encode(text)
+
+    msg.set_payload(text)
 
     # Create message headers
     # Don't expose emails addreses of the other subscribers, instead we
