From 26d64ec78f3f87ceceb13cca888335258c0f40cf Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 31 May 2022 23:41:50 +0300 Subject: [PATCH] mu-maildir: fix message_file_parts / empty flags Remove the suffix part even with no flags. Fixes: issue #2268 --- lib/mu-maildir.cc | 18 ++++++++---------- lib/mu-maildir.hh | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/mu-maildir.cc b/lib/mu-maildir.cc index b65573ec..7a563bb3 100644 --- a/lib/mu-maildir.cc +++ b/lib/mu-maildir.cc @@ -247,8 +247,6 @@ Mu::maildir_clear_links(const std::string& path) return Ok(); } - - Result Mu::maildir_from_path(const std::string& path, const std::string& root) { @@ -303,7 +301,7 @@ message_file_parts(const std::string& file) /* no suffix at all? */ if (pos == std::string::npos || - pos >= file.length() - 3 || + pos > file.length() - 3 || file[pos + 1] != '2' || file[pos + 2] != ',') return FileParts{ file, ':', {}}; @@ -559,11 +557,11 @@ check_determine_target_params (const std::string& old_path, Mu::Result -Mu::maildir_determine_target(const std::string& old_path, - const std::string& root_maildir_path, - const std::string& target_maildir, - Flags newflags, - bool new_name) +Mu::maildir_determine_target(const std::string& old_path, + const std::string& root_maildir_path, + const std::string& target_maildir, + Flags newflags, + bool new_name) { /* sanity checks */ if (const auto checked{check_determine_target_params( @@ -579,8 +577,8 @@ Mu::maildir_determine_target(const std::string& old_path, return Err(src.error()); const auto& [src_mdir, src_file, is_new] = *src; - /* if target_mdir is empty, we use the src_dir does not change - * (though cur/ maybe become new or vice-versa) */ + /* if target_mdir is empty, the src_dir does not change (though cur/ + * maybe become new or vice-versa) */ const auto dst_mdir{target_maildir.empty() ? src_mdir : root_maildir_path + target_maildir}; diff --git a/lib/mu-maildir.hh b/lib/mu-maildir.hh index f36f70c6..bb48c241 100644 --- a/lib/mu-maildir.hh +++ b/lib/mu-maildir.hh @@ -94,7 +94,7 @@ Result maildir_flags_from_path(const std::string& pathname); * @return the maildir or an Error */ Result maildir_from_path(const std::string& path, - const std::string& root); + const std::string& root); /** * Move a message file to another maildir. If the target file already exists, it