Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header
@ 2010-07-01 13:48 Sascha Silbe
  2010-07-01 14:33 ` Ben Walton
  2010-07-03  2:32 ` Rich Lane
  0 siblings, 2 replies; 7+ messages in thread
From: Sascha Silbe @ 2010-07-01 13:48 UTC (permalink / raw)
  To: sup-devel

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header
  2010-07-01 13:48 [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header Sascha Silbe
@ 2010-07-01 14:33 ` Ben Walton
  2010-07-01 19:34   ` Sascha Silbe
  2010-07-03  2:32 ` Rich Lane
  1 sibling, 1 reply; 7+ messages in thread
From: Ben Walton @ 2010-07-01 14:33 UTC (permalink / raw)
  To: sup-devel

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

Hi Sascha,

> +      #from = header["from"]

This patch looks good, but why include the commented line?

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

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header
  2010-07-01 14:33 ` Ben Walton
@ 2010-07-01 19:34   ` Sascha Silbe
  2010-07-01 20:11     ` Ben Walton
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Silbe @ 2010-07-01 19:34 UTC (permalink / raw)
  To: sup-devel


[-- Attachment #1.1: Type: text/plain, Size: 449 bytes --]

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

--
http://sascha.silbe.org/
http://www.infra-silbe.de/

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 143 bytes --]

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header
  2010-07-01 19:34   ` Sascha Silbe
@ 2010-07-01 20:11     ` Ben Walton
  2010-07-03 10:39       ` Sascha Silbe
  0 siblings, 1 reply; 7+ messages in thread
From: Ben Walton @ 2010-07-01 20:11 UTC (permalink / raw)
  To: sup-devel

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

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header
  2010-07-01 13:48 [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header Sascha Silbe
  2010-07-01 14:33 ` Ben Walton
@ 2010-07-03  2:32 ` Rich Lane
  2010-07-03 10:35   ` Sascha Silbe
  1 sibling, 1 reply; 7+ messages in thread
From: Rich Lane @ 2010-07-03  2:32 UTC (permalink / raw)
  To: Sascha Silbe; +Cc: sup-devel

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header
  2010-07-03  2:32 ` Rich Lane
@ 2010-07-03 10:35   ` Sascha Silbe
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Silbe @ 2010-07-03 10:35 UTC (permalink / raw)
  To: sup-devel


[-- Attachment #1.1: Type: text/plain, Size: 139 bytes --]

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

Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 143 bytes --]

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header
  2010-07-01 20:11     ` Ben Walton
@ 2010-07-03 10:39       ` Sascha Silbe
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Silbe @ 2010-07-03 10:39 UTC (permalink / raw)
  To: sup-devel


[-- Attachment #1.1: Type: text/plain, Size: 429 bytes --]

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/

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 143 bytes --]

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-03 10:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-01 13:48 [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header Sascha Silbe
2010-07-01 14:33 ` Ben Walton
2010-07-01 19:34   ` Sascha Silbe
2010-07-01 20:11     ` Ben Walton
2010-07-03 10:39       ` Sascha Silbe
2010-07-03  2:32 ` Rich Lane
2010-07-03 10:35   ` Sascha Silbe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox