Handle malformed SVG in Template

Prevent invalid data input for Editable Text
This commit is contained in:
WandererFan
2016-05-23 18:18:09 -04:00
committed by wmayer
parent 8a8d07d211
commit 87f62ce89e
3 changed files with 45 additions and 46 deletions

View File

@@ -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"

View File

@@ -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();