Normalize allowed paths before comparing them with imports

This commit is contained in:
Kamil Śliwak
2021-09-27 13:14:10 +02:00
parent a436abfb25
commit 52dd39212d
3 changed files with 86 additions and 99 deletions
+2 -11
View File
@@ -978,17 +978,8 @@ bool CommandLineParser::processArgs()
if (m_args.count(g_strAllowPaths))
{
vector<string> paths;
for (string const& path: boost::split(paths, m_args[g_strAllowPaths].as<string>(), boost::is_any_of(",")))
{
auto filesystem_path = boost::filesystem::path(path);
// If the given path had a trailing slash, the Boost filesystem
// path will have it's last component set to '.'. This breaks
// path comparison in later parts of the code, so we need to strip
// it.
if (filesystem_path.filename() == ".")
filesystem_path.remove_filename();
m_options.input.allowedDirectories.insert(filesystem_path);
}
for (string const& allowedPath: boost::split(paths, m_args[g_strAllowPaths].as<string>(), boost::is_any_of(",")))
m_options.input.allowedDirectories.insert(allowedPath);
}
if (m_args.count(g_strStopAfter))