whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Only search headers for List-Id and MID
Date Tue, 12 Feb 2019 15:17:18 GMT
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 <sebb@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}"


Mime
View raw message