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

From: Sascha Silbe <[email-masked]>
Date: Sat, 03 Jul 2010 10:39:21 +0000

Excerpts from Ben Walton's message of Thu Jul 01 20:11:08 +0000 2010:

> I'd resubmit with the lines removed.  It keeps the history cleaner.
Since the patch has already been merged in its current form, I won't post
a new one. It's no change in program behaviour or output and the comments
are not incorrect. Maybe they even help someone while debugging one day. ;)

Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Rich Lane <[email-masked]>
Date: Fri, 02 Jul 2010 22:32:23 -0400

Applied to master.

---

From: Sascha Silbe <[email-masked]>
Date: Sat, 03 Jul 2010 10:35:50 +0000

[several patches from this and other threads]
> Applied to master.
Thanks!

Sascha

---

From: Ben Walton <[email-masked]>
Date: Thu, 01 Jul 2010 16:11:08 -0400

Excerpts from Sascha Silbe's message of Thu Jul 01 15:34:47 -0400 2010:

> I just commented out a line that was only useful in combination with
> the line directly below it that was already commented out. If you
> prefer I can remove both of them instead (or do the change in a
> separate patch).

I'd resubmit with the lines removed.  It keeps the history cleaner.
Up to you of course, it's just my own preference I'm putting forward.

Thanks
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

---

From: Sascha Silbe <[email-masked]>
Date: Thu, 1 Jul 2010 13:48:13 +0000

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

---

From: Sascha Silbe <[email-masked]>
Date: Thu, 01 Jul 2010 19:34:47 +0000

Excerpts from Ben Walton's message of Thu Jul 01 14:33:22 +0000 2010:

> > +      #from = header["from"]
> 
> This patch looks good, but why include the commented line?
I just commented out a line that was only useful in combination with the
line directly below it that was already commented out. If you prefer
I can remove both of them instead (or do the change in a separate patch).

Sascha

---

From: Ben Walton <[email-masked]>
Date: Thu, 01 Jul 2010 10:33:22 -0400

Excerpts from Sascha Silbe's message of Thu Jul 01 09:48:13 -0400 2010:

Hi Sascha,

Thanks
-Ben