Sketcher: Escape text and font path in EditTextDialog
Escape user-provided text and font path strings before inserting them into the Python command string, preventing breakage or injection from strings containing quotes or backslashes.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
#include "CommandConstraints.h"
|
||||
#include "EditTextDialog.h"
|
||||
#include "ViewProviderSketch.h"
|
||||
#include "Utils.h"
|
||||
@@ -114,12 +115,14 @@ void EditTextDialog::on_buttonBox_accepted()
|
||||
}
|
||||
|
||||
// Send the updated 5-parameter call to Python
|
||||
std::string escText = escapeForPython(newText);
|
||||
std::string escFont = escapeForPython(newFontPath);
|
||||
Gui::cmdAppObjectArgs(
|
||||
sketch,
|
||||
"setTextAndFont(%i, '%s', '%s', %s, %s)",
|
||||
constrIndex,
|
||||
newText.c_str(),
|
||||
newFontPath.c_str(),
|
||||
escText.c_str(),
|
||||
escFont.c_str(),
|
||||
newIsHeight ? "True" : "False",
|
||||
isConstruction ? "True" : "False"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user