mirror of
https://github.com/chatmail/core.git
synced 2026-05-06 06:46:35 +03:00
refactor: remove indexing/slicing from parse_message_ids
This commit is contained in:
@@ -1915,18 +1915,17 @@ pub(crate) struct DeliveryReport {
|
|||||||
pub failure: bool,
|
pub failure: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::indexing_slicing)]
|
|
||||||
pub(crate) fn parse_message_ids(ids: &str) -> Vec<String> {
|
pub(crate) fn parse_message_ids(ids: &str) -> Vec<String> {
|
||||||
// take care with mailparse::msgidparse() that is pretty untolerant eg. wrt missing `<` or `>`
|
// take care with mailparse::msgidparse() that is pretty untolerant eg. wrt missing `<` or `>`
|
||||||
let mut msgids = Vec::new();
|
let mut msgids = Vec::new();
|
||||||
for id in ids.split_whitespace() {
|
for id in ids.split_whitespace() {
|
||||||
let mut id = id.to_string();
|
let mut id = id.to_string();
|
||||||
if id.starts_with('<') {
|
if let Some(id_without_prefix) = id.strip_prefix('<') {
|
||||||
id = id[1..].to_string();
|
id = id_without_prefix.to_string();
|
||||||
}
|
};
|
||||||
if id.ends_with('>') {
|
if let Some(id_without_suffix) = id.strip_suffix('>') {
|
||||||
id = id[..id.len() - 1].to_string();
|
id = id_without_suffix.to_string();
|
||||||
}
|
};
|
||||||
if !id.is_empty() {
|
if !id.is_empty() {
|
||||||
msgids.push(id);
|
msgids.push(id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user