[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header



If Message-ID contains only invalid characters (or none at all),
sanitize_message_id will return an empty string. As Message.parse_header
only checked for header existance, not validity, sup-dump could produce
a dump file that sup-sync would choke on.

We now fall back to a fake id for both missing and invalid Message-ID
headers.
---
 lib/sup/message.rb |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index a13fc0c..f273988 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -77,14 +77,15 @@ class Message
   def parse_header encoded_header
     header = SavingHash.new { |k| decode_header_field encoded_header[k] }
 
-    @id = if header["message-id"]
+    @id = ''
+    if header["message-id"]
       mid = header["message-id"] =~ /<(.+?)>/ ? $1 : header["message-id"]
-      sanitize_message_id mid
-    else
-      id = "sup-faked-" + Digest::MD5.hexdigest(raw_header)
-      from = header["from"]
+      @id = sanitize_message_id mid
+    end
+    if (not @id.include? '@') || @id.length < 6
+      @id = "sup-faked-" + Digest::MD5.hexdigest(raw_header)
+      #from = header["from"]
       #debug "faking non-existent message-id for message from #{from}: #{id}"
-      id
     end
 
     @from = Person.from_address(if header["from"]
-- 
1.7.1

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel