From: Sascha Silbe <sascha-pgp@silbe.org>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [sup-devel] [PATCH] parse_header: don't use empty or invalid Message-ID header
Date: Thu, 1 Jul 2010 13:48:13 +0000 [thread overview]
Message-ID: <1277992093-10600-1-git-send-email-sascha-pgp@silbe.org> (raw)
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
next reply other threads:[~2010-07-01 13:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-01 13:48 Sascha Silbe [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1277992093-10600-1-git-send-email-sascha-pgp@silbe.org \
--to=sascha-pgp@silbe.org \
--cc=sup-devel@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox