mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-21 14:57:26 -04:00
Merge pull request #4577
23ec5eb qml: escape untrusted text in RichText views (selsta)
This commit is contained in:
@@ -32,6 +32,7 @@ import QtQuick.Controls 2.2
|
|||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
import "../components" as MoneroComponents
|
import "../components" as MoneroComponents
|
||||||
|
import "../js/Utils.js" as Utils
|
||||||
import FontAwesome 1.0
|
import FontAwesome 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -306,7 +307,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
var title;
|
var title;
|
||||||
if (addressBookName) {
|
if (addressBookName) {
|
||||||
title = FontAwesome.addressBook + " " + addressBookName;
|
title = FontAwesome.addressBook + " " + Utils.htmlEscape(addressBookName);
|
||||||
} else {
|
} else {
|
||||||
title = qsTr("Monero address") + translationManager.emptyString;
|
title = qsTr("Monero address") + translationManager.emptyString;
|
||||||
}
|
}
|
||||||
|
|||||||
10
js/Utils.js
10
js/Utils.js
@@ -130,3 +130,13 @@ function parseDateStringOrRestoreHeightAsInteger(value) {
|
|||||||
}
|
}
|
||||||
return restoreHeight;
|
return restoreHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function htmlEscape(s) {
|
||||||
|
if (s === null || s === undefined)
|
||||||
|
return "";
|
||||||
|
return String(s)
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/"/g, """);
|
||||||
|
}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ Rectangle {
|
|||||||
consoleArea.append(msg);
|
consoleArea.append(msg);
|
||||||
}
|
}
|
||||||
function logMessage(msg){
|
function logMessage(msg){
|
||||||
msg = msg.trim();
|
msg = Utils.htmlEscape(msg.trim());
|
||||||
var color = MoneroComponents.Style.defaultFontColor;
|
var color = MoneroComponents.Style.defaultFontColor;
|
||||||
if(msg.toLowerCase().indexOf('error') >= 0){
|
if(msg.toLowerCase().indexOf('error') >= 0){
|
||||||
color = MoneroComponents.Style.errorColor;
|
color = MoneroComponents.Style.errorColor;
|
||||||
|
|||||||
Reference in New Issue
Block a user