Handle malformed SVG in Template
Prevent invalid data input for Editable Text
This commit is contained in:
@@ -115,9 +115,7 @@ void QGISVGTemplate::load(const QString &fileName)
|
||||
|
||||
Base::FileInfo fi(temp);
|
||||
|
||||
// make a temp file for FileIncluded Property
|
||||
std::string tempName = tmplte->PageResult.getExchangeTempFile();
|
||||
std::ostringstream ofile;
|
||||
std::ostringstream oStream;
|
||||
std::string tempendl = "--endOfLine--";
|
||||
std::string line;
|
||||
|
||||
@@ -128,11 +126,11 @@ void QGISVGTemplate::load(const QString &fileName)
|
||||
// check if the marker in the template is found
|
||||
if(line.find("<!-- DrawingContent -->") == std::string::npos) {
|
||||
// if not - write through
|
||||
ofile << line << tempendl;
|
||||
oStream << line << tempendl;
|
||||
}
|
||||
}
|
||||
|
||||
std::string outfragment(ofile.str());
|
||||
std::string outfragment(oStream.str());
|
||||
|
||||
// Find text tags with freecad:editable attribute and their matching tspans
|
||||
// keep tagRegex in sync with App/DrawSVGTemplate.cpp
|
||||
@@ -225,4 +223,4 @@ void QGISVGTemplate::updateView(bool update)
|
||||
draw();
|
||||
}
|
||||
|
||||
#include "moc_QGISVGTemplate.cpp"
|
||||
#include "moc_QGISVGTemplate.cpp"
|
||||
@@ -27,6 +27,8 @@
|
||||
#include<QLineEdit>
|
||||
#endif // #ifndef _PreCmp_
|
||||
|
||||
#include <QTextDocument>
|
||||
|
||||
#include "TemplateTextField.h"
|
||||
#include "DlgTemplateField.h"
|
||||
|
||||
@@ -55,6 +57,8 @@ void TemplateTextField::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
std::string newContent = "";
|
||||
if(uiCode == QDialog::Accepted) {
|
||||
std::string newContent = ui->getFieldContent();
|
||||
QString qsClean = Qt::escape(QString::fromStdString(newContent)); //Qt5 note: this becomes qsNewContent.toHtmlEscaped();
|
||||
newContent = qsClean.toUtf8().constData();
|
||||
tmplte->EditableTexts.setValue(fieldNameStr, newContent);
|
||||
}
|
||||
ui->deleteLater();
|
||||
|
||||
Reference in New Issue
Block a user