You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/02/12 15:17:18 UTC
[whimsy] branch master updated: Only search headers for List-Id and
MID
This is an automated email from the ASF dual-hosted git repository.
sebb 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 9622b73 Only search headers for List-Id and MID
9622b73 is described below
commit 9622b738c35094efe960dd2551f8da84a8dad8f2
Author: Sebb <se...@apache.org>
AuthorDate: Tue Feb 12 15:17:07 2019 +0000
Only search headers for List-Id and MID
---
tools/deliver.rb | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/deliver.rb b/tools/deliver.rb
index d1dfe8f..d7f1543 100644
--- a/tools/deliver.rb
+++ b/tools/deliver.rb
@@ -8,9 +8,7 @@ require 'fileutils'
MAIL_ROOT = '/srv/mail'
# get the message ID
-def self.getmid(message)
- # only search headers for MID
- hdrs = message[/\A(.*?)\r?\n\r?\n/m, 1] || ''
+def self.getmid(hdrs)
mid = hdrs[/^Message-ID:.*/i]
if mid =~ /^Message-ID:\s*$/i # no mid on the first line
# capture the next line and join them together
@@ -24,10 +22,13 @@ end
STDIN.binmode
mail = STDIN.read
+# only search headers for MID and List-ID etc
+hdrs = mail[/\A(.*?)\r?\n\r?\n/m, 1] || ''
+
# extract info
-dest = mail[/^List-Id: <(.*)>/, 1] || mail[/^Delivered-To.* (\S+)\s*$/, 1] || 'unknown'
+dest = hdrs[/^List-Id: <(.*)>/, 1] || hdrs[/^Delivered-To.* (\S+)\s*$/, 1] || 'unknown'
month = Time.now.strftime('%Y%m')
-hash = Digest::SHA1.hexdigest(getmid(mail) || mail)[0..9]
+hash = Digest::SHA1.hexdigest(getmid(hdrs) || mail)[0..9]
# build file name
file = "#{MAIL_ROOT}/#{dest[/^[-\w]+/]}/#{month}/#{hash}"