message-file: filter out non-file flags

Only take flags from file names that are actually file-flags, not random other
things
This commit is contained in:
Dirk-Jan C. Binnema 2022-06-10 00:45:08 +03:00
parent 9bf580de3d
commit 1ec03ce07c
2 changed files with 6 additions and 4 deletions

View File

@ -105,14 +105,16 @@ Mu::flags_from_path(const std::string& path)
/* it's cur/ message, so parse the file name */
const auto parts{message_file_parts(dirfile->file)};
auto flags{flags_from_absolute_expr(parts.flags_suffix,
true/*ignore invalid*/)};
true/*ignore invalid*/)};
if (!flags) {
/* LCOV_EXCL_START*/
return Err(Error{Error::Code::InvalidArgument,
"invalid flags ('%s')", parts.flags_suffix.c_str()});
/* LCOV_EXCL_STOP*/
} else
return Ok(std::move(flags.value()));
}
/* of course, only _file_ flags are allowed */
return Ok(flags_filter(flags.value(), MessageFlagCategory::Mailfile));
}

View File

@ -169,7 +169,7 @@ test_mu_msg_flags(void)
(Flags::Flagged | Flags::Seen |
Flags::HasAttachment)},
{MU_TESTMAILDIR4 "/special!2,Sabc",
(Flags::Seen|Flags::HasAttachment)}
(Flags::Seen)}
}};
for (auto&& test: tests) {