Source

trac-ticketlinks / trac / notification.py

Diff from to

File trac/notification.py

 from trac import __version__
 from trac.config import BoolOption, ExtensionOption, IntOption, Option
 from trac.core import *
-from trac.util.text import CRLF
+from trac.util.text import CRLF, fix_eol
 from trac.util.translation import _, deactivate, reactivate
 
 MAXHEADERLEN = 76
         '(?:[a-zA-Z0-9_-]+\.)+' # labels (but also allow '_')
         '[a-zA-Z](?:[-a-zA-Z\d]*[a-zA-Z\d])?' # TLD
         )
-eol_re = re.compile('\r?\n')
 
 
 class IEmailSender(Interface):
     
     def send(self, from_addr, recipients, message):
         # Ensure the message complies with RFC2822: use CRLF line endings
-        message = CRLF.join(eol_re.split(message))
+        message = fix_eol(message, CRLF)
         
         self.log.info("Sending notification through SMTP at %s:%d to %s"
                       % (self.smtp_server, self.smtp_port, recipients))
 
     def send(self, from_addr, recipients, message):
         # Use native line endings in message
-        message = os.linesep.join(eol_re.split(message))
+        message = fix_eol(message, os.linesep)
 
         self.log.info("Sending notification through sendmail at %s to %s"
                       % (self.sendmail_path, recipients))