mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
fix get_recipients with test
This commit is contained in:
@@ -969,9 +969,8 @@ fn get_recipients<'a, S: AsRef<str>, T: Iterator<Item = (S, S)>>(headers: T) ->
|
|||||||
let mut recipients: HashSet<String> = Default::default();
|
let mut recipients: HashSet<String> = Default::default();
|
||||||
|
|
||||||
for (hkey, hvalue) in headers {
|
for (hkey, hvalue) in headers {
|
||||||
let hkey = hkey.as_ref();
|
let hkey = hkey.as_ref().to_lowercase();
|
||||||
let hvalue = hvalue.as_ref();
|
let hvalue = hvalue.as_ref();
|
||||||
|
|
||||||
if hkey == "to" || hkey == "cc" {
|
if hkey == "to" || hkey == "cc" {
|
||||||
if let Ok(addrs) = mailparse::addrparse(hvalue) {
|
if let Ok(addrs) = mailparse::addrparse(hvalue) {
|
||||||
for addr in addrs.iter() {
|
for addr in addrs.iter() {
|
||||||
@@ -1058,6 +1057,17 @@ mod tests {
|
|||||||
assert_eq!(mimeparser.get_rfc724_mid(), None);
|
assert_eq!(mimeparser.get_rfc724_mid(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_recipients() {
|
||||||
|
let context = dummy_context();
|
||||||
|
let raw = include_bytes!("../test-data/message/mail_with_cc.txt");
|
||||||
|
let mimeparser = MimeParser::from_bytes(&context.ctx, &raw[..]).unwrap();
|
||||||
|
let recipients = get_recipients(mimeparser.header.iter());
|
||||||
|
assert!(recipients.contains("abc@bcd.com"));
|
||||||
|
assert!(recipients.contains("def@def.de"));
|
||||||
|
assert_eq!(recipients.len(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mailparse_content_type() {
|
fn test_mailparse_content_type() {
|
||||||
let ctype =
|
let ctype =
|
||||||
|
|||||||
14
test-data/message/mail_with_cc.txt
Normal file
14
test-data/message/mail_with_cc.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
Return-Path: <x@testrun.org>
|
||||||
|
Received: from hq5.merlinux.eu
|
||||||
|
by hq5.merlinux.eu (Dovecot) with LMTP id yRKOBakcfV1AewAAPzvFDg
|
||||||
|
; Sat, 14 Sep 2019 19:00:25 +0200
|
||||||
|
Received: from localhost (unknown 7.165.105.24])
|
||||||
|
by hq5.merlinux.eu (Postfix) with ESMTPSA id 8D9844E023;
|
||||||
|
Sat, 14 Sep 2019 19:00:22 +0200 (CEST)
|
||||||
|
message-id: <2dfdbde7@example.org>
|
||||||
|
Date: Sat, 14 Sep 2019 19:00:13 +0200
|
||||||
|
From: lmn <x@tux.org>
|
||||||
|
To: abc <abc@bcd.com>
|
||||||
|
CC: def <def@def.de>
|
||||||
|
|
||||||
|
hi
|
||||||
Reference in New Issue
Block a user