You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2018/05/01 17:05:18 UTC

[whimsy] branch master updated: cleanup broken header separators in secretary workbench

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 804b8dd  cleanup broken header separators in secretary workbench
804b8dd is described below

commit 804b8ddce52a0f95adf3c95c7e7f146f358933d5
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue May 1 13:05:01 2018 -0400

    cleanup broken header separators in secretary workbench
---
 www/secretary/workbench/models/message.rb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/www/secretary/workbench/models/message.rb b/www/secretary/workbench/models/message.rb
index bebbb67..708c66a 100644
--- a/www/secretary/workbench/models/message.rb
+++ b/www/secretary/workbench/models/message.rb
@@ -317,6 +317,16 @@ class Message
   def self.parse(message)
     mail = Mail.read_from_string(message)
 
+    # cleanup broken header separators.  Avoid copying the possibly large body
+    # unless a fixup is needed.
+    message.sub! /\AFrom .*\r?\n/i, '' if message =~ /^\AFrom /i
+    headers = mail[/(.*?)\r?\n\r?\n/m, 1]
+    if headers.include? "\n" and not headers.include? "\r\n"
+      headers, body = mail.split(/\r?\n\r?\n/, 2)
+      headers.gsub("\n", "\r\n")
+      message = "#{headers}\r\n\r\n#{body}"
+    end
+
     # parse from address
     begin
       from = liberal_email_parser(mail[:from].value).display_name

-- 
To stop receiving notification emails like this one, please contact
rubys@apache.org.