StartView: Escape file paths when loading

This commit is contained in:
Jookia
2024-07-02 19:17:35 +10:00
committed by Chris Hennes
parent 0f462500d9
commit 04cc890fd0

View File

@@ -45,6 +45,7 @@
#include <App/DocumentObject.h>
#include <App/Application.h>
#include <Base/Interpreter.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <gsl/pointers>
@@ -388,7 +389,9 @@ void StartView::postStart(PostStartBehavior behavior) const
void StartView::fileCardSelected(const QModelIndex& index)
{
auto file = index.data(static_cast<int>(Start::DisplayedFilesModelRoles::path)).toString();
auto command = std::string("FreeCAD.loadFile('") + file.toStdString() + "')";
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(file.toStdString().c_str());
escapedstr = Base::Tools::escapeEncodeFilename(escapedstr);
auto command = std::string("FreeCAD.loadFile('") + escapedstr + "')";
try {
Base::Interpreter().runString(command.c_str());
postStart(PostStartBehavior::doNotSwitchWorkbench);