Skip to content

Commit

Permalink
Escape html entities in console
Browse files Browse the repository at this point in the history
Fix #4020
  • Loading branch information
uglide committed Mar 2, 2018
1 parent 6011ea7 commit 12662d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/app/qmlutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,8 @@ void QmlUtils::deleteTextWrapper(QObject *w)
w->deleteLater();
}
}

QString QmlUtils::escapeHtmlEntities(const QString &t)
{
return t.toHtmlEscaped();
}
1 change: 1 addition & 0 deletions src/app/qmlutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ class QmlUtils : public QObject
Q_INVOKABLE void addNewValueToDynamicChart(QtCharts::QXYSeries* series, double value);
Q_INVOKABLE QObject* wrapLargeText(const QByteArray &text);
Q_INVOKABLE void deleteTextWrapper(QObject* w);
Q_INVOKABLE QString escapeHtmlEntities(const QString& t);
};
4 changes: 2 additions & 2 deletions src/qml/console/QConsole.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Rectangle {
function addOutput(text, type) {

if (type == "error") {
textArea.append("<span style='color: red'>" + text + '</span>')
textArea.append("<span style='color: red'>" + qmlUtils.escapeHtmlEntities(text) + '</span>')
} else {
textArea.append("<pre style='color: white'>" + text + '</pre>')
textArea.append("<pre style='color: white'>" + qmlUtils.escapeHtmlEntities(text) + '</pre>')
}

if (type == "complete" || type == "error") {
Expand Down

0 comments on commit 12662d1

Please sign in to comment.