Skip to content

Commit ebf6152

Browse files
committed
message_id could include a broken mojibake char
e.g. ruby-talk: 10751
1 parent 12e446a commit ebf6152

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/models/message.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def from_mail(mail, list, list_seq)
2929
from = mail.from.encode Encoding::UTF_8, Encoding::KOI8_R
3030
end
3131

32+
message_id = mail.message_id.encode Encoding::UTF_8, invalid: :replace, undef: :replace
33+
3234
# mail.in_reply_to returns strange Array object in some cases (?), so let's use the raw value
3335
parent_message_id = extract_message_id_from_in_reply_to(mail.header[:in_reply_to]&.value)
3436
parent_message = Message.find_by message_id_header: parent_message_id if parent_message_id
@@ -41,7 +43,7 @@ def from_mail(mail, list, list_seq)
4143
end
4244
end
4345

44-
new list_id: list.id, list_seq: list_seq, body: body, subject: subject, from: from, published_at: mail.date, message_id_header: mail.message_id, parent_id: parent_message&.id
46+
new list_id: list.id, list_seq: list_seq, body: body, subject: subject, from: from, published_at: mail.date, message_id_header: message_id, parent_id: parent_message&.id
4547
end
4648

4749
private def extract_message_id_from_in_reply_to(header)

0 commit comments

Comments
 (0)