fix: merge PythonFileUtils into PluginFsUtils

This commit is contained in:
Ian Chua
2026-07-16 20:40:32 +08:00
parent b779a7bfed
commit d9f8460a4e
18 changed files with 1051 additions and 1107 deletions

View File

@@ -14,11 +14,11 @@ namespace Slic3r {
// Path safety
// ---------------------------------------------------------------------------
bool is_inside_allowed_root(const std::filesystem::path& candidate, const std::filesystem::path& allowed_root)
bool is_inside_allowed_root(const boost::filesystem::path& candidate, const boost::filesystem::path& allowed_root)
{
namespace fs = std::filesystem;
namespace fs = boost::filesystem;
std::error_code ec;
boost::system::error_code ec;
// Canonicalize both paths. weakly_canonical resolves symlinks but does
// NOT require the path to exist — it canonicalizes the prefix that exists
@@ -78,7 +78,7 @@ bool is_inside_allowed_root(const std::filesystem::path& candidate, const std::f
thread_local std::string PluginAuditManager::m_current_plugin_key = "";
thread_local PluginAuditManager::AuditMode PluginAuditManager::m_audit_mode = PluginAuditManager::AuditMode::Loading;
thread_local std::vector<std::filesystem::path> PluginAuditManager::m_scoped_allowed_roots;
thread_local std::vector<boost::filesystem::path> PluginAuditManager::m_scoped_allowed_roots;
thread_local bool PluginAuditManager::m_has_last_violation = false;
thread_local AuditViolation PluginAuditManager::m_last_violation;
@@ -115,7 +115,7 @@ std::string PluginAuditManager::current_plugin() const { return m_current_plugin
void PluginAuditManager::clear_current_plugin() { m_current_plugin_key.clear(); }
void PluginAuditManager::add_global_allowed_root(const std::filesystem::path& root)
void PluginAuditManager::add_global_allowed_root(const boost::filesystem::path& root)
{
if (root.empty())
return;
@@ -125,7 +125,7 @@ void PluginAuditManager::add_global_allowed_root(const std::filesystem::path& ro
BOOST_LOG_TRIVIAL(info) << "[AUDIT] Global allowed root: " << root.string();
}
void PluginAuditManager::add_scoped_allowed_root(const std::filesystem::path& root)
void PluginAuditManager::add_scoped_allowed_root(const boost::filesystem::path& root)
{
if (root.empty())
return;
@@ -163,12 +163,12 @@ AuditDecision PluginAuditManager::check_open(const std::string& path_str, const
return {true, ""};
}
namespace fs = std::filesystem;
namespace fs = boost::filesystem;
fs::path candidate(path_str);
// Resolve relative paths against the current working directory
if (candidate.is_relative()) {
std::error_code ec;
boost::system::error_code ec;
candidate = fs::absolute(candidate, ec);
if (ec)
candidate = fs::path(path_str);