Browse Source

melib/imap: quote mailbox names on SELECT/EXAMINE

async
Manos Pitsidianakis 3 years ago
parent
commit
8235af9237
Signed by untrusted user: epilys GPG Key ID: 73627C2F690DF710
  1. 6
      melib/src/backends/imap.rs
  2. 2
      melib/src/backends/imap/operations.rs
  3. 4
      melib/src/backends/imap/watch.rs

6
melib/src/backends/imap.rs

@ -179,7 +179,7 @@ impl MailBackend for ImapType {
/* first SELECT the mailbox to get READ/WRITE permissions (because EXAMINE only
* returns READ-ONLY for both cases) */
exit_on_error!(&tx,
conn.send_command(format!("SELECT {}", folder_path).as_bytes())
conn.send_command(format!("SELECT \"{}\"", folder_path).as_bytes())
conn.read_response(&mut response)
);
let examine_response = protocol_parser::select_response(&response);
@ -211,7 +211,7 @@ impl MailBackend for ImapType {
}
/* reselecting the same mailbox with EXAMINE prevents expunging it */
exit_on_error!(&tx,
conn.send_command(format!("EXAMINE {}", folder_path).as_bytes())
conn.send_command(format!("EXAMINE \"{}\"", folder_path).as_bytes())
conn.read_response(&mut response)
);
@ -618,7 +618,7 @@ impl ImapType {
let folders_lck = self.folders.read()?;
let mut response = String::with_capacity(8 * 1024);
let mut conn = self.connection.lock()?;
conn.send_command(format!("EXAMINE {}", folders_lck[&folder_hash].path()).as_bytes())?;
conn.send_command(format!("EXAMINE \"{}\"", folders_lck[&folder_hash].path()).as_bytes())?;
conn.read_response(&mut response)?;
conn.send_command(format!("UID SEARCH CHARSET UTF-8 {}", query).as_bytes())?;
conn.read_response(&mut response)?;

2
melib/src/backends/imap/operations.rs

@ -78,7 +78,7 @@ impl BackendOp for ImapOp {
let mut response = String::with_capacity(8 * 1024);
{
let mut conn = self.connection.lock().unwrap();
conn.send_command(format!("SELECT {}", self.folder_path).as_bytes())?;
conn.send_command(format!("SELECT \"{}\"", &self.folder_path,).as_bytes())?;
conn.read_response(&mut response)?;
conn.send_command(format!("UID FETCH {} (FLAGS RFC822)", self.uid).as_bytes())?;
conn.read_response(&mut response)?;

4
melib/src/backends/imap/watch.rs

@ -148,7 +148,7 @@ pub fn idle(kit: ImapWatchKit) -> Result<()> {
folder_hash,
work_context,
thread_id,
conn.send_command(format!("SELECT {}", folder.path()).as_bytes())
conn.send_command(format!("SELECT \"{}\"", folder.path()).as_bytes())
conn.read_response(&mut response)
);
debug!("select response {}", &response);
@ -519,7 +519,7 @@ fn examine_updates(
folder_hash,
work_context,
thread_id,
conn.send_command(format!("EXAMINE {}", folder.path()).as_bytes())
conn.send_command(format!("EXAMINE \"{}\"", folder.path()).as_bytes())
conn.read_response(&mut response)
);
match protocol_parser::select_response(&response) {

Loading…
Cancel
Save