From 12662d17e0fe43b0b28e022a22252d6a937442b1 Mon Sep 17 00:00:00 2001 From: Igor Malinovskiy Date: Fri, 2 Mar 2018 16:26:43 +0200 Subject: [PATCH] Escape html entities in console Fix #4020 --- src/app/qmlutils.cpp | 5 +++++ src/app/qmlutils.h | 1 + src/qml/console/QConsole.qml | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/qmlutils.cpp b/src/app/qmlutils.cpp index eeb763cb9..c205e7d74 100644 --- a/src/app/qmlutils.cpp +++ b/src/app/qmlutils.cpp @@ -165,3 +165,8 @@ void QmlUtils::deleteTextWrapper(QObject *w) w->deleteLater(); } } + +QString QmlUtils::escapeHtmlEntities(const QString &t) +{ + return t.toHtmlEscaped(); +} diff --git a/src/app/qmlutils.h b/src/app/qmlutils.h index 4fee0ee44..c6116c961 100644 --- a/src/app/qmlutils.h +++ b/src/app/qmlutils.h @@ -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); }; diff --git a/src/qml/console/QConsole.qml b/src/qml/console/QConsole.qml index 0899d2d14..05ea0a5cd 100644 --- a/src/qml/console/QConsole.qml +++ b/src/qml/console/QConsole.qml @@ -38,9 +38,9 @@ Rectangle { function addOutput(text, type) { if (type == "error") { - textArea.append("" + text + '') + textArea.append("" + qmlUtils.escapeHtmlEntities(text) + '') } else { - textArea.append("
" + text + '
') + textArea.append("
" + qmlUtils.escapeHtmlEntities(text) + '
') } if (type == "complete" || type == "error") {