Fix some clippy lints
parent
fc25c7b165
commit
8c6c9806b5
|
@ -58,7 +58,8 @@ use super::*;
|
||||||
|
|
||||||
'file_loop: for (filename, ident) in filenames {
|
'file_loop: for (filename, ident) in filenames {
|
||||||
println!("cargo:rerun-if-changed={}", filename);
|
println!("cargo:rerun-if-changed={}", filename);
|
||||||
let mut file = File::open(&filename).expect(&format!("Unable to open file `{}`", filename));
|
let mut file = File::open(&filename)
|
||||||
|
.unwrap_or_else(|err| panic!("Unable to open file `{}` {}", filename, err));
|
||||||
|
|
||||||
let mut src = String::new();
|
let mut src = String::new();
|
||||||
file.read_to_string(&mut src).expect("Unable to read file");
|
file.read_to_string(&mut src).expect("Unable to read file");
|
||||||
|
@ -148,7 +149,7 @@ use super::*;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
output_string.extend(literal_struct.to_string().chars());
|
output_string.push_str(&literal_struct.to_string());
|
||||||
output_string.push_str("\n\n");
|
output_string.push_str("\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,9 +261,9 @@ impl RefreshEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct BackendEventConsumer(Arc<dyn Fn(AccountHash, BackendEvent) -> () + Send + Sync>);
|
pub struct BackendEventConsumer(Arc<dyn Fn(AccountHash, BackendEvent) + Send + Sync>);
|
||||||
impl BackendEventConsumer {
|
impl BackendEventConsumer {
|
||||||
pub fn new(b: Arc<dyn Fn(AccountHash, BackendEvent) -> () + Send + Sync>) -> Self {
|
pub fn new(b: Arc<dyn Fn(AccountHash, BackendEvent) + Send + Sync>) -> Self {
|
||||||
BackendEventConsumer(b)
|
BackendEventConsumer(b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ impl fmt::Debug for BackendEventConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for BackendEventConsumer {
|
impl Deref for BackendEventConsumer {
|
||||||
type Target = dyn Fn(AccountHash, BackendEvent) -> () + Send + Sync;
|
type Target = dyn Fn(AccountHash, BackendEvent) + Send + Sync;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&(*self.0)
|
&(*self.0)
|
||||||
|
|
|
@ -191,7 +191,6 @@ mod sqlite3_m {
|
||||||
row.get(2)?,
|
row.get(2)?,
|
||||||
))
|
))
|
||||||
})?
|
})?
|
||||||
.into_iter()
|
|
||||||
.collect::<std::result::Result<_, _>>()?;
|
.collect::<std::result::Result<_, _>>()?;
|
||||||
let mut max_uid = 0;
|
let mut max_uid = 0;
|
||||||
let mut env_lck = self.uid_store.envelopes.lock().unwrap();
|
let mut env_lck = self.uid_store.envelopes.lock().unwrap();
|
||||||
|
|
|
@ -825,7 +825,7 @@ impl ImapConnection {
|
||||||
let mut nonexistent = "blurdybloop".to_string();
|
let mut nonexistent = "blurdybloop".to_string();
|
||||||
{
|
{
|
||||||
let mailboxes = self.uid_store.mailboxes.lock().await;
|
let mailboxes = self.uid_store.mailboxes.lock().await;
|
||||||
while mailboxes.values().any(|m| m.imap_path() == &nonexistent) {
|
while mailboxes.values().any(|m| m.imap_path() == nonexistent) {
|
||||||
nonexistent.push('p');
|
nonexistent.push('p');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -905,7 +905,7 @@ impl ImapBlockingConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn err(&self) -> Option<&str> {
|
pub fn err(&self) -> Option<&str> {
|
||||||
self.err.as_ref().map(String::as_str)
|
self.err.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_stream<'a>(&'a mut self) -> impl Future<Output = Option<Vec<u8>>> + 'a {
|
pub fn as_stream<'a>(&'a mut self) -> impl Future<Output = Option<Vec<u8>>> + 'a {
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl BackendOp for ImapOp {
|
||||||
debug!(
|
debug!(
|
||||||
"fetch response is {} bytes and {} lines",
|
"fetch response is {} bytes and {} lines",
|
||||||
response.len(),
|
response.len(),
|
||||||
response.lines().collect::<Vec<&str>>().len()
|
response.lines().count()
|
||||||
);
|
);
|
||||||
let FetchResponse {
|
let FetchResponse {
|
||||||
uid: _uid,
|
uid: _uid,
|
||||||
|
@ -129,7 +129,7 @@ impl BackendOp for ImapOp {
|
||||||
debug!(
|
debug!(
|
||||||
"fetch response is {} bytes and {} lines",
|
"fetch response is {} bytes and {} lines",
|
||||||
response.len(),
|
response.len(),
|
||||||
response.lines().collect::<Vec<&str>>().len()
|
response.lines().count()
|
||||||
);
|
);
|
||||||
let v = protocol_parser::uid_fetch_flags_responses(response.as_bytes())
|
let v = protocol_parser::uid_fetch_flags_responses(response.as_bytes())
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
|
|
|
@ -211,7 +211,7 @@ impl std::fmt::Display for ResponseCode {
|
||||||
impl ResponseCode {
|
impl ResponseCode {
|
||||||
fn from(val: &str) -> ResponseCode {
|
fn from(val: &str) -> ResponseCode {
|
||||||
use ResponseCode::*;
|
use ResponseCode::*;
|
||||||
if !val.starts_with("[") {
|
if !val.starts_with('[') {
|
||||||
let msg = val.trim();
|
let msg = val.trim();
|
||||||
return Alert(msg.to_string());
|
return Alert(msg.to_string());
|
||||||
}
|
}
|
||||||
|
@ -669,7 +669,7 @@ pub fn fetch_responses(mut input: &str) -> ImapParseResult<Vec<FetchResponse<'_>
|
||||||
if let Some(el_alert) = el_alert {
|
if let Some(el_alert) = el_alert {
|
||||||
match &mut alert {
|
match &mut alert {
|
||||||
Some(Alert(ref mut alert)) => {
|
Some(Alert(ref mut alert)) => {
|
||||||
alert.extend(el_alert.0.chars());
|
alert.push_str(&el_alert.0);
|
||||||
}
|
}
|
||||||
a @ None => *a = Some(el_alert),
|
a @ None => *a = Some(el_alert),
|
||||||
}
|
}
|
||||||
|
@ -1123,13 +1123,13 @@ pub fn flags(input: &str) -> IResult<&str, (Flag, Vec<String>)> {
|
||||||
let mut keywords = Vec::new();
|
let mut keywords = Vec::new();
|
||||||
|
|
||||||
let mut input = input;
|
let mut input = input;
|
||||||
while !input.starts_with(")") && !input.is_empty() {
|
while !input.starts_with(')') && !input.is_empty() {
|
||||||
if input.starts_with("\\") {
|
if input.starts_with('\\') {
|
||||||
input = &input[1..];
|
input = &input[1..];
|
||||||
}
|
}
|
||||||
let mut match_end = 0;
|
let mut match_end = 0;
|
||||||
while match_end < input.len() {
|
while match_end < input.len() {
|
||||||
if input[match_end..].starts_with(" ") || input[match_end..].starts_with(")") {
|
if input[match_end..].starts_with(' ') || input[match_end..].starts_with(')') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
match_end += 1;
|
match_end += 1;
|
||||||
|
|
|
@ -307,7 +307,7 @@ impl MboxReader {
|
||||||
match self {
|
match self {
|
||||||
Self::MboxO => {
|
Self::MboxO => {
|
||||||
let next_offset: Option<(usize, usize)> = find_From__line!(input)
|
let next_offset: Option<(usize, usize)> = find_From__line!(input)
|
||||||
.and_then(|end| input.find(b"\n").and_then(|start| Some((start + 1, end))));
|
.and_then(|end| input.find(b"\n").map(|start| (start + 1, end)));
|
||||||
|
|
||||||
if let Some((start, len)) = next_offset {
|
if let Some((start, len)) = next_offset {
|
||||||
match Envelope::from_bytes(&input[start..len], None) {
|
match Envelope::from_bytes(&input[start..len], None) {
|
||||||
|
@ -363,33 +363,33 @@ impl MboxReader {
|
||||||
Ok(mut env) => {
|
Ok(mut env) => {
|
||||||
let mut flags = Flag::empty();
|
let mut flags = Flag::empty();
|
||||||
if env.other_headers().contains_key("Status") {
|
if env.other_headers().contains_key("Status") {
|
||||||
if env.other_headers()["Status"].contains("F") {
|
if env.other_headers()["Status"].contains('F') {
|
||||||
flags.set(Flag::FLAGGED, true);
|
flags.set(Flag::FLAGGED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["Status"].contains("A") {
|
if env.other_headers()["Status"].contains('A') {
|
||||||
flags.set(Flag::REPLIED, true);
|
flags.set(Flag::REPLIED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["Status"].contains("R") {
|
if env.other_headers()["Status"].contains('R') {
|
||||||
flags.set(Flag::SEEN, true);
|
flags.set(Flag::SEEN, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["Status"].contains("D") {
|
if env.other_headers()["Status"].contains('D') {
|
||||||
flags.set(Flag::TRASHED, true);
|
flags.set(Flag::TRASHED, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if env.other_headers().contains_key("X-Status") {
|
if env.other_headers().contains_key("X-Status") {
|
||||||
if env.other_headers()["X-Status"].contains("F") {
|
if env.other_headers()["X-Status"].contains('F') {
|
||||||
flags.set(Flag::FLAGGED, true);
|
flags.set(Flag::FLAGGED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["X-Status"].contains("A") {
|
if env.other_headers()["X-Status"].contains('A') {
|
||||||
flags.set(Flag::REPLIED, true);
|
flags.set(Flag::REPLIED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["X-Status"].contains("R") {
|
if env.other_headers()["X-Status"].contains('R') {
|
||||||
flags.set(Flag::SEEN, true);
|
flags.set(Flag::SEEN, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["X-Status"].contains("D") {
|
if env.other_headers()["X-Status"].contains('D') {
|
||||||
flags.set(Flag::TRASHED, true);
|
flags.set(Flag::TRASHED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["X-Status"].contains("T") {
|
if env.other_headers()["X-Status"].contains('T') {
|
||||||
flags.set(Flag::DRAFT, true);
|
flags.set(Flag::DRAFT, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ impl MboxReader {
|
||||||
}
|
}
|
||||||
Self::MboxRd => {
|
Self::MboxRd => {
|
||||||
let next_offset: Option<(usize, usize)> = find_From__line!(input)
|
let next_offset: Option<(usize, usize)> = find_From__line!(input)
|
||||||
.and_then(|end| input.find(b"\n").and_then(|start| Some((start + 1, end))));
|
.and_then(|end| input.find(b"\n").map(|start| (start + 1, end)));
|
||||||
|
|
||||||
if let Some((start, len)) = next_offset {
|
if let Some((start, len)) = next_offset {
|
||||||
match Envelope::from_bytes(&input[start..len], None) {
|
match Envelope::from_bytes(&input[start..len], None) {
|
||||||
|
@ -535,33 +535,33 @@ impl MboxReader {
|
||||||
Ok(mut env) => {
|
Ok(mut env) => {
|
||||||
let mut flags = Flag::empty();
|
let mut flags = Flag::empty();
|
||||||
if env.other_headers().contains_key("Status") {
|
if env.other_headers().contains_key("Status") {
|
||||||
if env.other_headers()["Status"].contains("F") {
|
if env.other_headers()["Status"].contains('F') {
|
||||||
flags.set(Flag::FLAGGED, true);
|
flags.set(Flag::FLAGGED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["Status"].contains("A") {
|
if env.other_headers()["Status"].contains('A') {
|
||||||
flags.set(Flag::REPLIED, true);
|
flags.set(Flag::REPLIED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["Status"].contains("R") {
|
if env.other_headers()["Status"].contains('R') {
|
||||||
flags.set(Flag::SEEN, true);
|
flags.set(Flag::SEEN, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["Status"].contains("D") {
|
if env.other_headers()["Status"].contains('D') {
|
||||||
flags.set(Flag::TRASHED, true);
|
flags.set(Flag::TRASHED, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if env.other_headers().contains_key("X-Status") {
|
if env.other_headers().contains_key("X-Status") {
|
||||||
if env.other_headers()["X-Status"].contains("F") {
|
if env.other_headers()["X-Status"].contains('F') {
|
||||||
flags.set(Flag::FLAGGED, true);
|
flags.set(Flag::FLAGGED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["X-Status"].contains("A") {
|
if env.other_headers()["X-Status"].contains('A') {
|
||||||
flags.set(Flag::REPLIED, true);
|
flags.set(Flag::REPLIED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["X-Status"].contains("R") {
|
if env.other_headers()["X-Status"].contains('R') {
|
||||||
flags.set(Flag::SEEN, true);
|
flags.set(Flag::SEEN, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["X-Status"].contains("D") {
|
if env.other_headers()["X-Status"].contains('D') {
|
||||||
flags.set(Flag::TRASHED, true);
|
flags.set(Flag::TRASHED, true);
|
||||||
}
|
}
|
||||||
if env.other_headers()["X-Status"].contains("T") {
|
if env.other_headers()["X-Status"].contains('T') {
|
||||||
flags.set(Flag::DRAFT, true);
|
flags.set(Flag::DRAFT, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -761,7 +761,7 @@ impl MailBackend for MboxType {
|
||||||
}
|
}
|
||||||
if done {
|
if done {
|
||||||
if payload.is_empty() {
|
if payload.is_empty() {
|
||||||
return Ok(None);
|
Ok(None)
|
||||||
} else {
|
} else {
|
||||||
let mut mailbox_lock = self.mailboxes.lock().unwrap();
|
let mut mailbox_lock = self.mailboxes.lock().unwrap();
|
||||||
let contents = std::mem::replace(&mut self.contents, vec![]);
|
let contents = std::mem::replace(&mut self.contents, vec![]);
|
||||||
|
@ -927,12 +927,7 @@ impl MailBackend for MboxType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DebouncedEvent::Rename(src, dest) => {
|
DebouncedEvent::Rename(src, dest) => {
|
||||||
if mailboxes
|
if mailboxes.lock().unwrap().values().any(|f| f.fs_path == src) {
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.values()
|
|
||||||
.any(|f| &f.fs_path == &src)
|
|
||||||
{
|
|
||||||
let mailbox_hash = get_path_hash!(&src);
|
let mailbox_hash = get_path_hash!(&src);
|
||||||
(sender)(
|
(sender)(
|
||||||
account_hash,
|
account_hash,
|
||||||
|
|
|
@ -104,7 +104,7 @@ impl Default for MailboxConf {
|
||||||
|
|
||||||
impl MailboxConf {
|
impl MailboxConf {
|
||||||
pub fn alias(&self) -> Option<&str> {
|
pub fn alias(&self) -> Option<&str> {
|
||||||
self.alias.as_ref().map(String::as_str)
|
self.alias.as_deref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -249,32 +249,27 @@ impl Envelope {
|
||||||
let name: HeaderName = name.try_into()?;
|
let name: HeaderName = name.try_into()?;
|
||||||
if name == "to" {
|
if name == "to" {
|
||||||
let parse_result = parser::address::rfc2822address_list(value);
|
let parse_result = parser::address::rfc2822address_list(value);
|
||||||
if parse_result.is_ok() {
|
if let Ok((_, value)) = parse_result {
|
||||||
let value = parse_result.unwrap().1;
|
|
||||||
self.set_to(value);
|
self.set_to(value);
|
||||||
};
|
};
|
||||||
} else if name == "cc" {
|
} else if name == "cc" {
|
||||||
let parse_result = parser::address::rfc2822address_list(value);
|
let parse_result = parser::address::rfc2822address_list(value);
|
||||||
if parse_result.is_ok() {
|
if let Ok((_, value)) = parse_result {
|
||||||
let value = parse_result.unwrap().1;
|
|
||||||
self.set_cc(value);
|
self.set_cc(value);
|
||||||
};
|
};
|
||||||
} else if name == "bcc" {
|
} else if name == "bcc" {
|
||||||
let parse_result = parser::address::rfc2822address_list(value);
|
let parse_result = parser::address::rfc2822address_list(value);
|
||||||
if parse_result.is_ok() {
|
if let Ok((_, value)) = parse_result {
|
||||||
let value = parse_result.unwrap().1;
|
|
||||||
self.set_bcc(value.to_vec());
|
self.set_bcc(value.to_vec());
|
||||||
};
|
};
|
||||||
} else if name == "from" {
|
} else if name == "from" {
|
||||||
let parse_result = parser::address::rfc2822address_list(value);
|
let parse_result = parser::address::rfc2822address_list(value);
|
||||||
if parse_result.is_ok() {
|
if let Ok((_, value)) = parse_result {
|
||||||
let value = parse_result.unwrap().1;
|
|
||||||
self.set_from(value);
|
self.set_from(value);
|
||||||
}
|
}
|
||||||
} else if name == "subject" {
|
} else if name == "subject" {
|
||||||
let parse_result = parser::encodings::phrase(value.trim(), false);
|
let parse_result = parser::encodings::phrase(value.trim(), false);
|
||||||
if parse_result.is_ok() {
|
if let Ok((_, value)) = parse_result {
|
||||||
let value = parse_result.unwrap().1;
|
|
||||||
self.set_subject(value);
|
self.set_subject(value);
|
||||||
};
|
};
|
||||||
} else if name == "message-id" {
|
} else if name == "message-id" {
|
||||||
|
@ -282,8 +277,8 @@ impl Envelope {
|
||||||
} else if name == "references" {
|
} else if name == "references" {
|
||||||
{
|
{
|
||||||
let parse_result = parser::address::references(value);
|
let parse_result = parser::address::references(value);
|
||||||
if parse_result.is_ok() {
|
if let Ok((_, value)) = parse_result {
|
||||||
for v in parse_result.unwrap().1 {
|
for v in value {
|
||||||
self.push_references(v);
|
self.push_references(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,8 +289,7 @@ impl Envelope {
|
||||||
in_reply_to = Some(value);
|
in_reply_to = Some(value);
|
||||||
} else if name == "date" {
|
} else if name == "date" {
|
||||||
let parse_result = parser::encodings::phrase(value, false);
|
let parse_result = parser::encodings::phrase(value, false);
|
||||||
if parse_result.is_ok() {
|
if let Ok((_, value)) = parse_result {
|
||||||
let value = parse_result.unwrap().1;
|
|
||||||
self.set_date(value.as_slice());
|
self.set_date(value.as_slice());
|
||||||
} else {
|
} else {
|
||||||
self.set_date(value);
|
self.set_date(value);
|
||||||
|
@ -510,7 +504,7 @@ impl Envelope {
|
||||||
pub fn in_reply_to(&self) -> Option<&MessageID> {
|
pub fn in_reply_to(&self) -> Option<&MessageID> {
|
||||||
self.in_reply_to
|
self.in_reply_to
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.or(self.references.as_ref().and_then(|r| r.refs.last()))
|
.or_else(|| self.references.as_ref().and_then(|r| r.refs.last()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn in_reply_to_display(&self) -> Option<Cow<str>> {
|
pub fn in_reply_to_display(&self) -> Option<Cow<str>> {
|
||||||
|
@ -563,7 +557,7 @@ impl Envelope {
|
||||||
while new_val
|
while new_val
|
||||||
.chars()
|
.chars()
|
||||||
.last()
|
.last()
|
||||||
.map(|c| char::is_control(c))
|
.map(char::is_control)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
new_val.pop();
|
new_val.pop();
|
||||||
|
|
|
@ -209,7 +209,7 @@ impl ContentType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_boundary(parts: &Vec<AttachmentBuilder>) -> String {
|
pub fn make_boundary(parts: &[AttachmentBuilder]) -> String {
|
||||||
use crate::email::compose::random::gen_boundary;
|
use crate::email::compose::random::gen_boundary;
|
||||||
let mut boundary = "bzz_bzz__bzz__".to_string();
|
let mut boundary = "bzz_bzz__bzz__".to_string();
|
||||||
let mut random_boundary = gen_boundary();
|
let mut random_boundary = gen_boundary();
|
||||||
|
@ -236,7 +236,7 @@ impl ContentType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boundary.extend(random_boundary.chars());
|
boundary.push_str(&random_boundary);
|
||||||
/* rfc134
|
/* rfc134
|
||||||
* "The only mandatory parameter for the multipart Content-Type is the boundary parameter,
|
* "The only mandatory parameter for the multipart Content-Type is the boundary parameter,
|
||||||
* which consists of 1 to 70 characters from a set of characters known to be very robust
|
* which consists of 1 to 70 characters from a set of characters known to be very robust
|
||||||
|
@ -253,7 +253,7 @@ impl ContentType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parts(&self) -> Option<&Vec<Attachment>> {
|
pub fn parts(&self) -> Option<&[Attachment]> {
|
||||||
if let ContentType::Multipart { ref parts, .. } = self {
|
if let ContentType::Multipart { ref parts, .. } = self {
|
||||||
Some(parts)
|
Some(parts)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -200,7 +200,7 @@ impl AttachmentBuilder {
|
||||||
if n.eq_ignore_ascii_case(b"name") {
|
if n.eq_ignore_ascii_case(b"name") {
|
||||||
if let Ok(v) = crate::email::parser::encodings::phrase(v.trim(), false)
|
if let Ok(v) = crate::email::parser::encodings::phrase(v.trim(), false)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|(_, r)| Ok(String::from_utf8_lossy(r).to_string()))
|
.map(|(_, r)| String::from_utf8_lossy(r).to_string())
|
||||||
{
|
{
|
||||||
name = Some(v);
|
name = Some(v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -529,7 +529,7 @@ impl Attachment {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mime_type(&self) -> String {
|
pub fn mime_type(&self) -> String {
|
||||||
format!("{}", self.content_type).to_string()
|
self.content_type.to_string()
|
||||||
}
|
}
|
||||||
pub fn attachments(&self) -> Vec<Attachment> {
|
pub fn attachments(&self) -> Vec<Attachment> {
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
|
@ -599,37 +599,35 @@ impl Attachment {
|
||||||
pub fn into_raw(&self) -> String {
|
pub fn into_raw(&self) -> String {
|
||||||
let mut ret = String::with_capacity(2 * self.raw.len());
|
let mut ret = String::with_capacity(2 * self.raw.len());
|
||||||
fn into_raw_helper(a: &Attachment, ret: &mut String) {
|
fn into_raw_helper(a: &Attachment, ret: &mut String) {
|
||||||
ret.extend(
|
ret.push_str(&format!(
|
||||||
format!(
|
"Content-Transfer-Encoding: {}\n",
|
||||||
"Content-Transfer-Encoding: {}\n",
|
a.content_transfer_encoding
|
||||||
a.content_transfer_encoding
|
));
|
||||||
)
|
|
||||||
.chars(),
|
|
||||||
);
|
|
||||||
match &a.content_type {
|
match &a.content_type {
|
||||||
ContentType::Text {
|
ContentType::Text {
|
||||||
kind: _,
|
kind: _,
|
||||||
parameters,
|
parameters,
|
||||||
charset,
|
charset,
|
||||||
} => {
|
} => {
|
||||||
ret.extend(
|
ret.push_str(&format!(
|
||||||
format!("Content-Type: {}; charset={}", a.content_type, charset).chars(),
|
"Content-Type: {}; charset={}",
|
||||||
);
|
a.content_type, charset
|
||||||
|
));
|
||||||
for (n, v) in parameters {
|
for (n, v) in parameters {
|
||||||
ret.push_str("; ");
|
ret.push_str("; ");
|
||||||
ret.extend(String::from_utf8_lossy(n).chars());
|
ret.push_str(&String::from_utf8_lossy(n));
|
||||||
ret.push_str("=");
|
ret.push_str("=");
|
||||||
if v.contains(&b' ') {
|
if v.contains(&b' ') {
|
||||||
ret.push_str("\"");
|
ret.push_str("\"");
|
||||||
}
|
}
|
||||||
ret.extend(String::from_utf8_lossy(v).chars());
|
ret.push_str(&String::from_utf8_lossy(v));
|
||||||
if v.contains(&b' ') {
|
if v.contains(&b' ') {
|
||||||
ret.push_str("\"");
|
ret.push_str("\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.push_str("\n\n");
|
ret.push_str("\n\n");
|
||||||
ret.extend(String::from_utf8_lossy(a.body()).chars());
|
ret.push_str(&String::from_utf8_lossy(a.body()));
|
||||||
}
|
}
|
||||||
ContentType::Multipart {
|
ContentType::Multipart {
|
||||||
boundary,
|
boundary,
|
||||||
|
@ -637,42 +635,41 @@ impl Attachment {
|
||||||
parts,
|
parts,
|
||||||
} => {
|
} => {
|
||||||
let boundary = String::from_utf8_lossy(boundary);
|
let boundary = String::from_utf8_lossy(boundary);
|
||||||
ret.extend(format!("Content-Type: {}; boundary={}", kind, boundary).chars());
|
ret.push_str(&format!("Content-Type: {}; boundary={}", kind, boundary));
|
||||||
if *kind == MultipartType::Signed {
|
if *kind == MultipartType::Signed {
|
||||||
ret.extend(
|
ret.push_str("; micalg=pgp-sha512; protocol=\"application/pgp-signature\"");
|
||||||
"; micalg=pgp-sha512; protocol=\"application/pgp-signature\"".chars(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
ret.push('\n');
|
ret.push('\n');
|
||||||
|
|
||||||
let boundary_start = format!("\n--{}\n", boundary);
|
let boundary_start = format!("\n--{}\n", boundary);
|
||||||
for p in parts {
|
for p in parts {
|
||||||
ret.extend(boundary_start.chars());
|
ret.push_str(&boundary_start);
|
||||||
into_raw_helper(p, ret);
|
into_raw_helper(p, ret);
|
||||||
}
|
}
|
||||||
ret.extend(format!("--{}--\n\n", boundary).chars());
|
ret.push_str(&format!("--{}--\n\n", boundary));
|
||||||
}
|
}
|
||||||
ContentType::MessageRfc822 => {
|
ContentType::MessageRfc822 => {
|
||||||
ret.extend(format!("Content-Type: {}\n\n", a.content_type).chars());
|
ret.push_str(&format!("Content-Type: {}\n\n", a.content_type));
|
||||||
ret.extend(String::from_utf8_lossy(a.body()).chars());
|
ret.push_str(&String::from_utf8_lossy(a.body()));
|
||||||
}
|
}
|
||||||
ContentType::PGPSignature => {
|
ContentType::PGPSignature => {
|
||||||
ret.extend(format!("Content-Type: {}\n\n", a.content_type).chars());
|
ret.push_str(&format!("Content-Type: {}\n\n", a.content_type));
|
||||||
ret.extend(String::from_utf8_lossy(a.body()).chars());
|
ret.push_str(&String::from_utf8_lossy(a.body()));
|
||||||
}
|
}
|
||||||
ContentType::OctetStream { ref name } => {
|
ContentType::OctetStream { ref name } => {
|
||||||
if let Some(name) = name {
|
if let Some(name) = name {
|
||||||
ret.extend(
|
ret.push_str(&format!(
|
||||||
format!("Content-Type: {}; name={}\n\n", a.content_type, name).chars(),
|
"Content-Type: {}; name={}\n\n",
|
||||||
);
|
a.content_type, name
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
ret.extend(format!("Content-Type: {}\n\n", a.content_type).chars());
|
ret.push_str(&format!("Content-Type: {}\n\n", a.content_type));
|
||||||
}
|
}
|
||||||
ret.push_str(&BASE64_MIME.encode(a.body()).trim());
|
ret.push_str(&BASE64_MIME.encode(a.body()).trim());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
ret.extend(format!("Content-Type: {}\n\n", a.content_type).chars());
|
ret.push_str(&format!("Content-Type: {}\n\n", a.content_type));
|
||||||
ret.extend(String::from_utf8_lossy(a.body()).chars());
|
ret.push_str(&String::from_utf8_lossy(a.body()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -737,11 +734,9 @@ fn decode_rec_helper<'a>(a: &'a Attachment, filter: &mut Option<Filter<'a>>) ->
|
||||||
match a.content_type {
|
match a.content_type {
|
||||||
ContentType::Other { .. } => Vec::new(),
|
ContentType::Other { .. } => Vec::new(),
|
||||||
ContentType::Text { .. } => decode_helper(a, filter),
|
ContentType::Text { .. } => decode_helper(a, filter),
|
||||||
ContentType::OctetStream { ref name } => name
|
ContentType::OctetStream { ref name } => {
|
||||||
.clone()
|
name.clone().unwrap_or_else(|| a.mime_type()).into_bytes()
|
||||||
.unwrap_or_else(|| a.mime_type())
|
}
|
||||||
.to_string()
|
|
||||||
.into_bytes(),
|
|
||||||
ContentType::PGPSignature => Vec::new(),
|
ContentType::PGPSignature => Vec::new(),
|
||||||
ContentType::MessageRfc822 => {
|
ContentType::MessageRfc822 => {
|
||||||
let temp = decode_rfc822(a.body());
|
let temp = decode_rfc822(a.body());
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub fn encode_header(value: &str) -> String {
|
||||||
*
|
*
|
||||||
* Whitespaces inside encoded tokens must be greedily taken,
|
* Whitespaces inside encoded tokens must be greedily taken,
|
||||||
* instead of splitting each non-ascii word into separate encoded tokens. */
|
* instead of splitting each non-ascii word into separate encoded tokens. */
|
||||||
if !g.split_whitespace().next().is_none() {
|
if g.split_whitespace().next().is_some() {
|
||||||
ret.push_str(&format!(
|
ret.push_str(&format!(
|
||||||
"=?UTF-8?B?{}?=",
|
"=?UTF-8?B?{}?=",
|
||||||
BASE64_MIME
|
BASE64_MIME
|
||||||
|
|
|
@ -417,7 +417,7 @@ pub mod headers {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let mut ptr = 0;
|
let mut ptr = 0;
|
||||||
let mut name: &[u8] = &input[0..0];
|
let mut name: &[u8] = &[];
|
||||||
let mut has_colon = false;
|
let mut has_colon = false;
|
||||||
/* field-name = 1*<any CHAR, excluding CTLs, SPACE, and ":"> */
|
/* field-name = 1*<any CHAR, excluding CTLs, SPACE, and ":"> */
|
||||||
for (i, x) in input.iter().enumerate() {
|
for (i, x) in input.iter().enumerate() {
|
||||||
|
@ -573,7 +573,7 @@ pub mod headers {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let mut ptr = 0;
|
let mut ptr = 0;
|
||||||
let mut name: &[u8] = &input[0..0];
|
let mut name: &[u8] = &[];
|
||||||
/* field-name = 1*<any CHAR, excluding CTLs, SPACE, and ":"> */
|
/* field-name = 1*<any CHAR, excluding CTLs, SPACE, and ":"> */
|
||||||
for (i, x) in input.iter().enumerate() {
|
for (i, x) in input.iter().enumerate() {
|
||||||
if *x == b':' {
|
if *x == b':' {
|
||||||
|
@ -635,7 +635,7 @@ pub mod headers {
|
||||||
pub fn headers_raw(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
pub fn headers_raw(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||||
if input.is_empty() {
|
if input.is_empty() {
|
||||||
return Err(nom::Err::Error(
|
return Err(nom::Err::Error(
|
||||||
(input, format!("headers_raw(): input is empty",)).into(),
|
(input, "headers_raw(): input is empty").into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
for i in 0..input.len() {
|
for i in 0..input.len() {
|
||||||
|
@ -1507,7 +1507,7 @@ pub mod address {
|
||||||
{
|
{
|
||||||
move |i: I| {
|
move |i: I| {
|
||||||
let mut res = SmallVec::new();
|
let mut res = SmallVec::new();
|
||||||
let mut i = i.clone();
|
let mut i = i;
|
||||||
|
|
||||||
// Parse the first element
|
// Parse the first element
|
||||||
match f(i.clone()) {
|
match f(i.clone()) {
|
||||||
|
|
|
@ -158,11 +158,11 @@ impl fmt::Display for MeliError {
|
||||||
if let Some(summary) = self.summary.as_ref() {
|
if let Some(summary) = self.summary.as_ref() {
|
||||||
writeln!(f, "Summary: {}", summary)?;
|
writeln!(f, "Summary: {}", summary)?;
|
||||||
}
|
}
|
||||||
let ret = write!(f, "{}", self.details)?;
|
write!(f, "{}", self.details)?;
|
||||||
if let Some(source) = self.source.as_ref() {
|
if let Some(source) = self.source.as_ref() {
|
||||||
write!(f, "\nCaused by: {}", source)?;
|
write!(f, "\nCaused by: {}", source)?;
|
||||||
}
|
}
|
||||||
Ok(ret)
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,16 +168,16 @@ pub mod shellexpand {
|
||||||
let c_to_str = c.as_os_str().to_str();
|
let c_to_str = c.as_os_str().to_str();
|
||||||
match c_to_str {
|
match c_to_str {
|
||||||
Some("~") => {
|
Some("~") => {
|
||||||
if let Some(home_dir) = std::env::var("HOME").ok() {
|
if let Ok(home_dir) = std::env::var("HOME") {
|
||||||
ret.push(home_dir)
|
ret.push(home_dir)
|
||||||
} else {
|
} else {
|
||||||
return PathBuf::new();
|
return PathBuf::new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(var) if var.starts_with("$") => {
|
Some(var) if var.starts_with('$') => {
|
||||||
let env_name = var.split_at(1).1;
|
let env_name = var.split_at(1).1;
|
||||||
if env_name.chars().all(char::is_uppercase) {
|
if env_name.chars().all(char::is_uppercase) {
|
||||||
ret.push(std::env::var(env_name).unwrap_or(String::new()));
|
ret.push(std::env::var(env_name).unwrap_or_default());
|
||||||
} else {
|
} else {
|
||||||
ret.push(c);
|
ret.push(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ pub mod query_parser {
|
||||||
whitespace_wrap(match_literal("subject:")),
|
whitespace_wrap(match_literal("subject:")),
|
||||||
whitespace_wrap(literal()),
|
whitespace_wrap(literal()),
|
||||||
)
|
)
|
||||||
.map(|term| Query::Subject(term))
|
.map(Query::Subject)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from<'a>() -> impl Parser<'a, Query> {
|
fn from<'a>() -> impl Parser<'a, Query> {
|
||||||
|
@ -117,7 +117,7 @@ pub mod query_parser {
|
||||||
whitespace_wrap(match_literal("from:")),
|
whitespace_wrap(match_literal("from:")),
|
||||||
whitespace_wrap(literal()),
|
whitespace_wrap(literal()),
|
||||||
)
|
)
|
||||||
.map(|term| Query::From(term))
|
.map(Query::From)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to<'a>() -> impl Parser<'a, Query> {
|
fn to<'a>() -> impl Parser<'a, Query> {
|
||||||
|
@ -125,7 +125,7 @@ pub mod query_parser {
|
||||||
whitespace_wrap(match_literal("to:")),
|
whitespace_wrap(match_literal("to:")),
|
||||||
whitespace_wrap(literal()),
|
whitespace_wrap(literal()),
|
||||||
)
|
)
|
||||||
.map(|term| Query::To(term))
|
.map(Query::To)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cc<'a>() -> impl Parser<'a, Query> {
|
fn cc<'a>() -> impl Parser<'a, Query> {
|
||||||
|
@ -133,7 +133,7 @@ pub mod query_parser {
|
||||||
whitespace_wrap(match_literal("cc:")),
|
whitespace_wrap(match_literal("cc:")),
|
||||||
whitespace_wrap(literal()),
|
whitespace_wrap(literal()),
|
||||||
)
|
)
|
||||||
.map(|term| Query::Cc(term))
|
.map(Query::Cc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bcc<'a>() -> impl Parser<'a, Query> {
|
fn bcc<'a>() -> impl Parser<'a, Query> {
|
||||||
|
@ -141,7 +141,7 @@ pub mod query_parser {
|
||||||
whitespace_wrap(match_literal("bcc:")),
|
whitespace_wrap(match_literal("bcc:")),
|
||||||
whitespace_wrap(literal()),
|
whitespace_wrap(literal()),
|
||||||
)
|
)
|
||||||
.map(|term| Query::Bcc(term))
|
.map(Query::Bcc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn or<'a>() -> impl Parser<'a, Query> {
|
fn or<'a>() -> impl Parser<'a, Query> {
|
||||||
|
@ -212,14 +212,14 @@ pub mod query_parser {
|
||||||
})
|
})
|
||||||
.and_then(|(rest, flags_list)| {
|
.and_then(|(rest, flags_list)| {
|
||||||
if let Ok(r) = flags_list
|
if let Ok(r) = flags_list
|
||||||
.split(",")
|
.split(',')
|
||||||
.map(|t| {
|
.map(|t| {
|
||||||
either(quoted_string(), string())
|
either(quoted_string(), string())
|
||||||
.parse_complete(t)
|
.parse_complete(t)
|
||||||
.map(|(_, r)| r)
|
.map(|(_, r)| r)
|
||||||
})
|
})
|
||||||
.collect::<std::result::Result<Vec<String>, &str>>()
|
.collect::<std::result::Result<Vec<String>, &str>>()
|
||||||
.map(|v| Flags(v))
|
.map(Flags)
|
||||||
{
|
{
|
||||||
Ok((rest, r))
|
Ok((rest, r))
|
||||||
} else {
|
} else {
|
||||||
|
@ -245,13 +245,13 @@ pub mod query_parser {
|
||||||
move |input| {
|
move |input| {
|
||||||
let (rest, query_a): (&'a str, Query) = if let Ok(q) = parentheses_query()
|
let (rest, query_a): (&'a str, Query) = if let Ok(q) = parentheses_query()
|
||||||
.parse(input)
|
.parse(input)
|
||||||
.or(from().parse(input))
|
.or_else(|_| from().parse(input))
|
||||||
.or(to().parse(input))
|
.or_else(|_| to().parse(input))
|
||||||
.or(cc().parse(input))
|
.or_else(|_| cc().parse(input))
|
||||||
.or(bcc().parse(input))
|
.or_else(|_| bcc().parse(input))
|
||||||
.or(subject().parse(input))
|
.or_else(|_| subject().parse(input))
|
||||||
.or(flags().parse(input))
|
.or_else(|_| flags().parse(input))
|
||||||
.or(has_attachment().parse(input))
|
.or_else(|_| has_attachment().parse(input))
|
||||||
{
|
{
|
||||||
Ok(q)
|
Ok(q)
|
||||||
} else if let Ok((rest, query_a)) = not().parse(input) {
|
} else if let Ok((rest, query_a)) = not().parse(input) {
|
||||||
|
@ -399,11 +399,10 @@ impl<'de> Deserialize<'de> for Query {
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
let s = <String>::deserialize(deserializer)?;
|
let s = <String>::deserialize(deserializer)?;
|
||||||
let _q = query().parse(&s);
|
let ret = query()
|
||||||
if let Some(q) = _q.ok() {
|
.parse(&s)
|
||||||
Ok(q.1)
|
.map(|(_, q)| q)
|
||||||
} else {
|
.map_err(|err| de::Error::custom(format!("invalid query value: {}", err)));
|
||||||
Err(de::Error::custom("invalid query value"))
|
ret
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl<'s> Iterator for WordBreakIter<'s> {
|
||||||
}
|
}
|
||||||
self.input = self.input.trim_start_matches(|c| c == ' ');
|
self.input = self.input.trim_start_matches(|c| c == ' ');
|
||||||
if self.input.starts_with('\n') {
|
if self.input.starts_with('\n') {
|
||||||
let ret = &self.input[0..0];
|
let ret = "";
|
||||||
self.input = &self.input[1..];
|
self.input = &self.input[1..];
|
||||||
return Some(ret);
|
return Some(ret);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ impl<'s> Iterator for WordBreakIter<'s> {
|
||||||
} else {
|
} else {
|
||||||
/* graphemes.len() < width */
|
/* graphemes.len() < width */
|
||||||
let ret = self.input;
|
let ret = self.input;
|
||||||
self.input = &self.input[0..0];
|
self.input = "";
|
||||||
Some(ret)
|
Some(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -776,7 +776,7 @@ mod alg {
|
||||||
minima: &mut Vec<usize>,
|
minima: &mut Vec<usize>,
|
||||||
breaks: &mut Vec<usize>,
|
breaks: &mut Vec<usize>,
|
||||||
width: usize,
|
width: usize,
|
||||||
offsets: &Vec<usize>,
|
offsets: &[usize],
|
||||||
) {
|
) {
|
||||||
let mut stack = Vec::new();
|
let mut stack = Vec::new();
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
|
@ -846,7 +846,7 @@ mod alg {
|
||||||
prev = b.0;
|
prev = b.0;
|
||||||
}
|
}
|
||||||
if &text[prev..] != "\n" {
|
if &text[prev..] != "\n" {
|
||||||
words.push(text[prev..].trim_end_matches("\n"));
|
words.push(text[prev..].trim_end_matches('\n'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let count = words.len();
|
let count = words.len();
|
||||||
|
|
|
@ -686,7 +686,7 @@ impl Threads {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|| ThreadNodeHash::new());
|
.unwrap_or_else(ThreadNodeHash::new);
|
||||||
{
|
{
|
||||||
let mut node = self.thread_nodes.entry(new_id).or_default();
|
let mut node = self.thread_nodes.entry(new_id).or_default();
|
||||||
node.message = Some(env_hash);
|
node.message = Some(env_hash);
|
||||||
|
|
Loading…
Reference in New Issue