mirror of
https://github.com/stalwartlabs/mail-parser.git
synced 2026-11-28 16:01:16 +00:00
Reject dates with invalid month names
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
mail-parser 0.11.4
|
||||
================================
|
||||
- Reject dates with invalid month names.
|
||||
|
||||
mail-parser 0.11.3
|
||||
================================
|
||||
- Fix panic with messages containing corrupted attachments (#145)
|
||||
|
||||
+17
-11
@@ -359,17 +359,7 @@
|
||||
},
|
||||
{
|
||||
"header": "13 zzz 2021 09:55:06 +0200",
|
||||
"expected": {
|
||||
"year": 2021,
|
||||
"month": 0,
|
||||
"day": 13,
|
||||
"hour": 9,
|
||||
"minute": 55,
|
||||
"second": 6,
|
||||
"tz_before_gmt": false,
|
||||
"tz_hour": 2,
|
||||
"tz_minute": 0
|
||||
}
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"header": "by 2002:aa7:cd10:0:b0:45c:2c83:1208 with SMTP id b16-20020aa7cd10000000b0045c2c831208mr4220805edw.81.1665423075119;\n\tMon, 10 Oct 2022 10:31:15 -0700 (PDT)",
|
||||
@@ -440,5 +430,21 @@
|
||||
"tz_hour": 0,
|
||||
"tz_minute": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"header": "Tue, 7 All 2026 19:14:51 +0000",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"header": "Tue, 7 Bog 2026 19:14:51 +0000",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"header": "Tue, 7 Sjj 2026 19:14:51 +0000",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"header": "Tue, 7 00 2026 19:14:51 +0000",
|
||||
"expected": null
|
||||
}
|
||||
]
|
||||
@@ -412,6 +412,14 @@ impl<'x> MessageStream<'x> {
|
||||
}
|
||||
|
||||
if pos >= 6 {
|
||||
let month: u8 = if month_pos == 3 {
|
||||
MONTH_MAP.get(month_hash).copied().unwrap_or(0)
|
||||
} else {
|
||||
parts[1] as u8
|
||||
};
|
||||
if !(1..=12).contains(&month) {
|
||||
return HeaderValue::Empty;
|
||||
}
|
||||
HeaderValue::DateTime(DateTime {
|
||||
year: if (0..=49).contains(&parts[2]) {
|
||||
parts[2] + 2000
|
||||
@@ -420,11 +428,7 @@ impl<'x> MessageStream<'x> {
|
||||
} else {
|
||||
parts[2]
|
||||
} as u16,
|
||||
month: if month_pos == 3 && month_hash <= 30 {
|
||||
MONTH_MAP[month_hash]
|
||||
} else {
|
||||
parts[1] as u8
|
||||
},
|
||||
month,
|
||||
day: parts[0] as u8,
|
||||
hour: parts[3] as u8,
|
||||
minute: parts[4] as u8,
|
||||
|
||||
Reference in New Issue
Block a user