Skip to content

Commit 14cb20c

Browse files
committed
Bump to mail-parser 0.10.0
1 parent 18bb92b commit 14cb20c

File tree

9 files changed

+33
-42
lines changed

9 files changed

+33
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
mail-auth 0.6.1
2+
================================
3+
- Bump to `mail-parser` 0.10.0.
4+
15
mail-auth 0.6.0
26
================================
37
- `Resolver` is now `MessageAuthenticator`.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ test = []
2626
ahash = "0.8.0"
2727
ed25519-dalek = { version = "2.0", optional = true }
2828
flate2 = "1.0.25"
29-
mail-parser = { version = "0.9", features = ["ludicrous_mode", "full_encoding"] }
29+
mail-parser = { path = "../mail-parser", features = ["full_encoding"] }
30+
#mail-parser = { version = "0.10", features = ["full_encoding"] }
3031
mail-builder = { version = "0.3", features = ["ludicrous_mode"] }
3132
quick-xml = { version = "0.37", optional = true }
3233
ring = { version = "0.17", optional = true }

resources/arf/002.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"feedback_type": "Abuse",
3-
"arrival_date": 1110290400,
3+
"arrival_date": 1110304800,
44
"authentication_results": [
55
"mail.example.com;\n spf=fail [email protected]"
66
],

src/common/message.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,17 @@ impl<'x> AuthenticatedMessage<'x> {
4545
HeaderName::MessageId => {
4646
message.message_id_header_present = true;
4747
}
48-
HeaderName::Other(text) => {
49-
let name = text.as_bytes();
50-
match name.first() {
51-
Some(b'D' | b'd') => {
52-
if name.eq_ignore_ascii_case(b"DKIM-Signature") {
53-
message.parse_dkim(name, value, strict);
54-
}
55-
}
56-
Some(b'A' | b'a') => {
57-
if name.eq_ignore_ascii_case(b"ARC-Authentication-Results") {
58-
message.parse_aar(name, value);
59-
} else if name.eq_ignore_ascii_case(b"ARC-Seal") {
60-
message.parse_as(name, value);
61-
} else if name.eq_ignore_ascii_case(b"ARC-Message-Signature") {
62-
message.parse_ams(name, value, strict);
63-
}
64-
}
65-
_ => (),
66-
}
48+
HeaderName::DkimSignature => {
49+
message.parse_dkim(name, value, strict);
50+
}
51+
HeaderName::ArcAuthenticationResults => {
52+
message.parse_aar(name, value);
53+
}
54+
HeaderName::ArcSeal => {
55+
message.parse_as(name, value);
56+
}
57+
HeaderName::ArcMessageSignature => {
58+
message.parse_ams(name, value, strict);
6759
}
6860
_ => (),
6961
}

src/common/resolver.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,10 @@ impl MessageAuthenticator {
211211
Ok(ipv4_lookup.entry)
212212
}
213213

214-
pub async fn ipv4_lookup_raw<'x>(
215-
&self,
216-
key: &str,
217-
) -> crate::Result<DnsEntry<Arc<Vec<Ipv4Addr>>>> {
214+
pub async fn ipv4_lookup_raw(&self, key: &str) -> crate::Result<DnsEntry<Arc<Vec<Ipv4Addr>>>> {
218215
#[cfg(any(test, feature = "test"))]
219216
if true {
220-
return mock_resolve(key.as_ref());
217+
return mock_resolve(key);
221218
}
222219

223220
let ipv4_lookup = self.0.ipv4_lookup(Name::from_str_relaxed(key)?).await?;
@@ -257,13 +254,10 @@ impl MessageAuthenticator {
257254
Ok(ipv6_lookup.entry)
258255
}
259256

260-
pub async fn ipv6_lookup_raw<'x>(
261-
&self,
262-
key: &str,
263-
) -> crate::Result<DnsEntry<Arc<Vec<Ipv6Addr>>>> {
257+
pub async fn ipv6_lookup_raw(&self, key: &str) -> crate::Result<DnsEntry<Arc<Vec<Ipv6Addr>>>> {
264258
#[cfg(any(test, feature = "test"))]
265259
if true {
266-
return mock_resolve(key.as_ref());
260+
return mock_resolve(key);
267261
}
268262

269263
let ipv6_lookup = self.0.ipv6_lookup(Name::from_str_relaxed(key)?).await?;
@@ -326,7 +320,7 @@ impl MessageAuthenticator {
326320
}
327321
}
328322

329-
pub async fn ptr_lookup<'x>(
323+
pub async fn ptr_lookup(
330324
&self,
331325
addr: IpAddr,
332326
cache: Option<&impl ResolverCache<IpAddr, Arc<Vec<String>>>>,
@@ -392,8 +386,8 @@ impl MessageAuthenticator {
392386
) -> crate::Result<bool> {
393387
let key = key.into_fqdn();
394388

395-
if cache_ipv4.map_or(false, |c| c.get(key.as_ref()).is_some())
396-
|| cache_ipv6.map_or(false, |c| c.get(key.as_ref()).is_some())
389+
if cache_ipv4.is_some_and(|c| c.get(key.as_ref()).is_some())
390+
|| cache_ipv6.is_some_and(|c| c.get(key.as_ref()).is_some())
397391
{
398392
return Ok(true);
399393
}
@@ -404,7 +398,7 @@ impl MessageAuthenticator {
404398
.await
405399
{
406400
Ok(result) => Ok(result.as_lookup().record_iter().any(|r| {
407-
r.data().map_or(false, |d| {
401+
r.data().is_some_and(|d| {
408402
matches!(
409403
d.record_type(),
410404
hickory_resolver::proto::rr::RecordType::A

src/dmarc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl DmarcOutput {
183183
pub fn requested_reports(&self) -> bool {
184184
self.record
185185
.as_ref()
186-
.map_or(false, |r| !r.rua.is_empty() || !r.ruf.is_empty())
186+
.is_some_and(|r| !r.rua.is_empty() || !r.ruf.is_empty())
187187
}
188188

189189
/// Returns the failure reporting options

src/report/dmarc/parse.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ impl Report {
3737
if part
3838
.content_type()
3939
.and_then(|ct| ct.subtype())
40-
.map_or(false, |t| t.eq_ignore_ascii_case("xml"))
40+
.is_some_and( |t| t.eq_ignore_ascii_case("xml"))
4141
|| part
4242
.attachment_name()
4343
.and_then(|n| n.rsplit_once('.'))
44-
.map_or(false, |(_, e)| e.eq_ignore_ascii_case("xml")) =>
44+
.is_some_and( |(_, e)| e.eq_ignore_ascii_case("xml")) =>
4545
{
4646
match Report::parse_xml(report.as_bytes()) {
4747
Ok(feedback) => return Ok(feedback),
@@ -286,7 +286,7 @@ impl PolicyPublished {
286286
b"testing" => {
287287
p.testing = reader
288288
.next_value::<String>(buf)?
289-
.map_or(false, |s| s.eq_ignore_ascii_case("y"));
289+
.is_some_and( |s| s.eq_ignore_ascii_case("y"));
290290
}
291291
b"fo" => {
292292
p.fo = reader.next_value::<String>(buf)?;

src/report/tlsrpt/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ mod tests {
132132

133133
for file in fs::read_dir(&path).unwrap() {
134134
let file = file.as_ref().unwrap().path();
135-
if !file.extension().map_or(false, |e| e == "json") {
135+
if file.extension().is_none_or(|e| e != "json") {
136136
continue;
137137
}
138138
let rpt = TlsReport::parse_json(&fs::read(&file).unwrap())
@@ -144,7 +144,7 @@ mod tests {
144144

145145
for file in fs::read_dir(&path).unwrap() {
146146
let mut file = file.as_ref().unwrap().path();
147-
if !file.extension().map_or(false, |e| e == "eml") {
147+
if file.extension().is_none_or(|e| e != "eml") {
148148
continue;
149149
}
150150
let rpt = TlsReport::parse_rfc5322(&fs::read(&file).unwrap())

src/spf/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl TxtRecordParser for Spf {
2828
let mut record = bytes.iter();
2929
if !matches!(record.key(), Some(k) if k == V)
3030
|| !record.match_bytes(b"spf1")
31-
|| record.next().map_or(false, |v| !v.is_ascii_whitespace())
31+
|| record.next().is_some_and( |v| !v.is_ascii_whitespace())
3232
{
3333
return Err(Error::InvalidRecordType);
3434
}

0 commit comments

Comments
 (0)