[tor-commits] [bridgedb/develop] Fix bug in MailResponse.write() multiline string handling.

isis at torproject.org isis at torproject.org
Fri Jun 6 20:40:38 UTC 2014


commit 212d6dfe9866a9a2d6c60dd6e43e93e6f14908ac
Author: Isis Lovecruft <isis at torproject.org>
Date:   Wed May 21 04:20:56 2014 +0000

    Fix bug in MailResponse.write() multiline string handling.
    
    The bridgedb.email.server.MailResponse.write() method wasn't properly
    converting '\n' newlines in multiline strings to SMTP-formatted '\r\n'
    newlines.
    
     * FIXES multiline string newline replacement bug in
       bridgedb.email.server.MailResponse.write() method.
---
 lib/bridgedb/email/server.py |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/bridgedb/email/server.py b/lib/bridgedb/email/server.py
index 079960a..43acd99 100644
--- a/lib/bridgedb/email/server.py
+++ b/lib/bridgedb/email/server.py
@@ -338,8 +338,13 @@ class MailResponse(object):
 
     def write(self, line):
         """Any **line** written to me will have ``'\r\n'`` appended to it."""
-        self.mailfile.write(self._buff(line + '\r\n'))
-        self.mailfile.flush()
+        if line.find('\n') != -1:
+            # If **line** contains newlines, send it to :meth:`writelines` to
+            # break it up so that we can replace them with '\r\n':
+            self.writelines(line)
+        else:
+            self.mailfile.write(self._buff(line + '\r\n'))
+            self.mailfile.flush()
 
     def writelines(self, lines):
         """Calls :meth:`write` for each line in **lines**."""





More information about the tor-commits mailing list