diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index e6bf3f8deb..78ac9e54e8 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -201,6 +202,7 @@ void CmdTechDrawNewPage::activated(int iMsg) //why is "Template" property set twice? -wf // once to set DrawSVGTemplate.Template to OS template file name + templateFileName = Base::Tools::escapeEncodeFilename(templateFileName); doCommand(Doc,"App.activeDocument().%s.Template = \"%s\"",TemplateName.c_str(), templateFileName.toUtf8().constData()); // once to set Page.Template to DrawSVGTemplate.Name doCommand(Doc,"App.activeDocument().%s.Template = App.activeDocument().%s",PageName.c_str(),TemplateName.c_str()); @@ -974,6 +976,7 @@ void CmdTechDrawSymbol::activated(int iMsg) if (!filename.isEmpty()) { std::string FeatName = getUniqueObjectName("Symbol"); + filename = Base::Tools::escapeEncodeFilename(filename); openCommand("Create Symbol"); #if PY_MAJOR_VERSION < 3 doCommand(Doc,"f = open(unicode(\"%s\",'utf-8'),'r')",(const char*)filename.toUtf8()); @@ -1256,6 +1259,7 @@ void CmdTechDrawExportPageDxf::activated(int iMsg) std::string PageName = page->getNameInDocument(); openCommand("Save page to dxf"); doCommand(Doc,"import TechDraw"); + fileName = Base::Tools::escapeEncodeFilename(fileName); doCommand(Doc,"TechDraw.writeDXFPage(App.activeDocument().%s,u\"%s\")",PageName.c_str(),(const char*)fileName.toUtf8()); commitCommand(); } diff --git a/src/Mod/TechDraw/Gui/CommandDecorate.cpp b/src/Mod/TechDraw/Gui/CommandDecorate.cpp index e0107314f2..db246a0d41 100644 --- a/src/Mod/TechDraw/Gui/CommandDecorate.cpp +++ b/src/Mod/TechDraw/Gui/CommandDecorate.cpp @@ -32,6 +32,7 @@ #include +# include # include # include # include @@ -408,6 +409,7 @@ void CmdTechDrawImage::activated(int iMsg) if (!fileName.isEmpty()) { std::string FeatName = getUniqueObjectName("Image"); + fileName = Base::Tools::escapeEncodeFilename(fileName); openCommand("Create Image"); doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewImage','%s')",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.ImageFile = '%s'",FeatName.c_str(),fileName.toUtf8().constData()); diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index a1f56e3316..cc80a387ce 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -49,6 +49,7 @@ #include "MDIViewPage.h" #include +#include #include #include #include @@ -924,6 +925,7 @@ void MDIViewPage::saveDXF(std::string fileName) { TechDraw::DrawPage* page = m_vpPage->getDrawPage(); std::string PageName = page->getNameInDocument(); + fileName = Base::Tools::escapeEncodeFilename(fileName); Gui::Command::openCommand("Save page to dxf"); Gui::Command::doCommand(Gui::Command::Doc,"import TechDraw"); Gui::Command::doCommand(Gui::Command::Doc,"TechDraw.writeDXFPage(App.activeDocument().%s,u\"%s\")", diff --git a/src/Mod/TechDraw/Gui/TaskActiveView.cpp b/src/Mod/TechDraw/Gui/TaskActiveView.cpp index 0461e2dfa9..32baecdd1f 100644 --- a/src/Mod/TechDraw/Gui/TaskActiveView.cpp +++ b/src/Mod/TechDraw/Gui/TaskActiveView.cpp @@ -135,6 +135,7 @@ TechDraw::DrawViewSymbol* TaskActiveView::createActiveView(void) tempFile.close(); std::string fileSpec = Base::Tools::toStdString(tempFile.fileName()); + fileSpec = Base::Tools::escapeEncodeFilename(fileSpec); //double estScale = Grabber3d::copyActiveViewToSvgFile(appDoc, fileSpec, diff --git a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp index 6bd525f305..caccdd54f0 100644 --- a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp +++ b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp @@ -447,6 +447,7 @@ TechDraw::DrawWeldSymbol* TaskWeldingSymbol::createWeldingSymbol(void) symbolName.c_str(), altWeldText.c_str()); std::string tailText = Base::Tools::toStdString(ui->leTailText->text()); + tailText = Base::Tools::escapeEncodeString(tailText); Command::doCommand(Command::Doc,"App.activeDocument().%s.TailText = '%s'", symbolName.c_str(), tailText.c_str()); @@ -481,6 +482,7 @@ void TaskWeldingSymbol::updateWeldingSymbol(void) symbolName.c_str(), altWeldText.c_str()); std::string tailText = Base::Tools::toStdString(ui->leTailText->text()); + tailText = Base::Tools::escapeEncodeString(tailText); Command::doCommand(Command::Doc,"App.activeDocument().%s.TailText = '%s'", symbolName.c_str(), tailText.c_str()); } @@ -490,10 +492,14 @@ std::vector TaskWeldingSymbol::createTiles(void) // Base::Console().Message("TWS::createTiles()\n"); std::vector tileFeats; std::string tileType("TechDraw::DrawTileWeld"); - + collectArrowData(); if (m_arrowOut.toBeSaved) { std::string tileName = m_leadFeat->getDocument()->getUniqueObjectName("DrawTileWeld"); + std::string symbolPath = Base::Tools::escapeEncodeString(m_arrowOut.symbolPath); + std::string leftText = Base::Tools::escapeEncodeString(m_arrowOut.leftText); + std::string rightText = Base::Tools::escapeEncodeString(m_arrowOut.rightText); + std::string centerText = Base::Tools::escapeEncodeString(m_arrowOut.centerText); Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')", tileType.c_str(),tileName.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.TileRow = %d", @@ -501,13 +507,13 @@ std::vector TaskWeldingSymbol::createTiles(void) Command::doCommand(Command::Doc,"App.activeDocument().%s.TileColumn = %d", tileName.c_str(), m_arrowOut.col); Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = '%s'", - tileName.c_str(), m_arrowOut.symbolPath.c_str()); + tileName.c_str(), symbolPath.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'", - tileName.c_str(), m_arrowOut.leftText.c_str()); + tileName.c_str(), leftText.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'", - tileName.c_str(), m_arrowOut.rightText.c_str()); + tileName.c_str(), rightText.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'", - tileName.c_str(), m_arrowOut.centerText.c_str()); + tileName.c_str(), centerText.c_str()); App::DocumentObject* newTile = m_leadFeat->getDocument()->getObject(tileName.c_str()); if (newTile == nullptr) { throw Base::RuntimeError("TaskWeldingSymbol - new tile object not found"); @@ -530,16 +536,20 @@ std::vector TaskWeldingSymbol::createTiles(void) Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = ''", tileName.c_str()); } else { + std::string symbolPath = Base::Tools::escapeEncodeString(m_otherOut.symbolPath); Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = '%s'", - tileName.c_str(), m_otherOut.symbolPath.c_str()); + tileName.c_str(), symbolPath.c_str()); } + std::string leftText = Base::Tools::escapeEncodeString(m_otherOut.leftText); + std::string rightText = Base::Tools::escapeEncodeString(m_otherOut.rightText); + std::string centerText = Base::Tools::escapeEncodeString(m_otherOut.centerText); Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'", - tileName.c_str(), m_otherOut.leftText.c_str()); + tileName.c_str(), leftText.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'", - tileName.c_str(), m_otherOut.rightText.c_str()); + tileName.c_str(), rightText.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'", - tileName.c_str(), m_otherOut.centerText.c_str()); + tileName.c_str(), centerText.c_str()); App::DocumentObject* newTile = m_leadFeat->getDocument()->getObject(tileName.c_str()); if (newTile == nullptr) { throw Base::RuntimeError("TaskWeldingSymbol - new tile object not found"); @@ -584,16 +594,20 @@ std::vector TaskWeldingSymbol::updateTiles(void) Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = ''", tileName.c_str()); } else { + std::string symbolPath = Base::Tools::escapeEncodeString(m_arrowOut.symbolPath); Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = '%s'", - tileName.c_str(), m_arrowOut.symbolPath.c_str()); + tileName.c_str(), symbolPath.c_str()); } - + + std::string leftText = Base::Tools::escapeEncodeString(m_arrowOut.leftText); + std::string rightText = Base::Tools::escapeEncodeString(m_arrowOut.rightText); + std::string centerText = Base::Tools::escapeEncodeString(m_arrowOut.centerText); Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'", - tileName.c_str(), m_arrowOut.leftText.c_str()); + tileName.c_str(), leftText.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'", - tileName.c_str(), m_arrowOut.rightText.c_str()); + tileName.c_str(), rightText.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'", - tileName.c_str(), m_arrowOut.centerText.c_str()); + tileName.c_str(), centerText.c_str()); } if (m_otherDirty) { @@ -627,16 +641,20 @@ std::vector TaskWeldingSymbol::updateTiles(void) Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = ''", tileName.c_str()); } else { + std::string symbolPath = Base::Tools::escapeEncodeString(m_otherOut.symbolPath); Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = '%s'", - tileName.c_str(), m_otherOut.symbolPath.c_str()); + tileName.c_str(), symbolPath.c_str()); } + std::string leftText = Base::Tools::escapeEncodeString(m_otherOut.leftText); + std::string rightText = Base::Tools::escapeEncodeString(m_otherOut.rightText); + std::string centerText = Base::Tools::escapeEncodeString(m_otherOut.centerText); Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'", - tileName.c_str(), m_otherOut.leftText.c_str()); + tileName.c_str(), leftText.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'", - tileName.c_str(), m_otherOut.rightText.c_str()); + tileName.c_str(), rightText.c_str()); Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'", - tileName.c_str(), m_otherOut.centerText.c_str()); + tileName.c_str(), centerText.c_str()); } }