melib/imap: small fixes
- Ignore final line ("M__ OK ...") when parsing FETCH response. - Remove unnecessary import and reword some error messagesasync
parent
254028fa47
commit
77d9cef6fc
|
@ -630,7 +630,10 @@ impl ImapType {
|
|||
conn.send_command(b"LIST \"\" \"*\"")?;
|
||||
conn.read_response(&mut res)?;
|
||||
debug!("out: {}", &res);
|
||||
for l in res.lines().map(|l| l.trim()) {
|
||||
let mut lines = res.lines();
|
||||
/* Remove "M__ OK .." line */
|
||||
lines.next_back();
|
||||
for l in lines.map(|l| l.trim()) {
|
||||
if let Ok(mut folder) =
|
||||
protocol_parser::list_folder_result(l.as_bytes()).to_full_result()
|
||||
{
|
||||
|
@ -666,7 +669,10 @@ impl ImapType {
|
|||
conn.send_command(b"LSUB \"\" \"*\"")?;
|
||||
conn.read_response(&mut res)?;
|
||||
debug!("out: {}", &res);
|
||||
for l in res.lines().map(|l| l.trim()) {
|
||||
let mut lines = res.lines();
|
||||
/* Remove "M__ OK .." line */
|
||||
lines.next_back();
|
||||
for l in lines.map(|l| l.trim()) {
|
||||
if let Ok(subscription) =
|
||||
protocol_parser::list_folder_result(l.as_bytes()).to_full_result()
|
||||
{
|
||||
|
|
|
@ -27,7 +27,6 @@ use std::io::Write;
|
|||
extern crate native_tls;
|
||||
use fnv::FnvHashSet;
|
||||
use native_tls::TlsConnector;
|
||||
use std::borrow::Cow;
|
||||
use std::iter::FromIterator;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
|
|
@ -350,7 +350,7 @@ pub fn uid_fetch_response(input: &str) -> ImapParseResult<UidFetchResponse<'_>>
|
|||
ret.uid = usize::from_str(unsafe { std::str::from_utf8_unchecked(uid) }).unwrap();
|
||||
} else {
|
||||
return debug!(Err(MeliError::new(format!(
|
||||
"217Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
"Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
input
|
||||
))));
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ pub fn uid_fetch_response(input: &str) -> ImapParseResult<UidFetchResponse<'_>>
|
|||
i += (input.len() - i - rest.len()) + 1;
|
||||
} else {
|
||||
return debug!(Err(MeliError::new(format!(
|
||||
"228Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
"Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
input
|
||||
))));
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ pub fn uid_fetch_response(input: &str) -> ImapParseResult<UidFetchResponse<'_>>
|
|||
i += input.len() - i - rest.len();
|
||||
} else {
|
||||
return debug!(Err(MeliError::new(format!(
|
||||
"248Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
"Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
input
|
||||
))));
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ pub fn uid_fetch_response(input: &str) -> ImapParseResult<UidFetchResponse<'_>>
|
|||
i += input.len() - i - rest.len();
|
||||
} else {
|
||||
return debug!(Err(MeliError::new(format!(
|
||||
"264Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
"Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
&input[i..]
|
||||
))));
|
||||
}
|
||||
|
@ -408,9 +408,9 @@ pub fn uid_fetch_response(input: &str) -> ImapParseResult<UidFetchResponse<'_>>
|
|||
} else if input.as_bytes()[struct_ptr] == b')' {
|
||||
if parenth_level == 0 {
|
||||
return debug!(Err(MeliError::new(format!(
|
||||
"280Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
&input[struct_ptr..]
|
||||
))));
|
||||
"Unexpected input while parsing UID FETCH response. Got: `{:.40}`",
|
||||
&input[struct_ptr..]
|
||||
))));
|
||||
}
|
||||
parenth_level -= 1;
|
||||
if parenth_level == 0 {
|
||||
|
|
Loading…
Reference in New Issue