Skip to content

Commit 0794845

Browse files
authored
Merge pull request #25 from ruby/handle-ruby-list-2840
Workaround ruby-list:2840
2 parents 8acbf0f + e22296c commit 0794845

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/models/message.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
BLADE_BUCKET_REGION = 'ap-northeast-1'
22
BLADE_BUCKET_NAME = 'blade.ruby-lang.org'
33

4+
require 'kconv'
5+
46
class Message < ApplicationRecord
57
# Not really sure we will utlize this configuration,
68
# but I don't want to make this column.
@@ -19,8 +21,14 @@ def self.from_s3(list_name, list_seq)
1921
end
2022

2123
def self.from_string(str)
22-
hs, body = str.encode('utf-8', invalid: :replace).split(/\n\n/, 2)
23-
headers = hs.split(/\n/).map { |line|
24+
headers_str, body = str.split(/\n\n/, 2)
25+
26+
# Not really sure this is from the original email, or while making
27+
# blade.ruby-lang.org's S3 archive, but there are emails without
28+
# a proper Form header, such as ruby-list:2840.
29+
headers_str = Kconv.toutf8(headers_str).gsub(/\r\n/, '')
30+
31+
headers = headers_str.split(/\n/).map { |line|
2432
line.split(/:\s+/, 2)
2533
}.to_h
2634

0 commit comments

Comments
 (0)