summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-01-31 20:24:31 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-31 20:24:31 (GMT)
commitb66315290cf80b090f1b66eef021c811d1ea0b74 (patch)
tree003896ead18bb4ca285ba036f79b4ee9c9b0497a
parent34029b7c0d076f96cd35c9a87ae6303f14d4ff14 (diff)
downloadswift-b66315290cf80b090f1b66eef021c811d1ea0b74.zip
swift-b66315290cf80b090f1b66eef021c811d1ea0b74.tar.bz2
Escape XML tags in FreeDesktop notifications.
Resolves: #756
-rw-r--r--Swift/QtUI/FreeDesktopNotifier.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Swift/QtUI/FreeDesktopNotifier.cpp b/Swift/QtUI/FreeDesktopNotifier.cpp
index e027043..6db1da1 100644
--- a/Swift/QtUI/FreeDesktopNotifier.cpp
+++ b/Swift/QtUI/FreeDesktopNotifier.cpp
@@ -31,6 +31,11 @@ void FreeDesktopNotifier::showMessage(Type type, const String& subject, const St
return;
}
+ QString body = P2QSTRING(description);
+ body = body.replace("&", "&amp;");
+ body = body.replace("<", "&lt;");
+ body = body.replace(">", "&gt;");
+
int timeout = (type == IncomingMessage || type == SystemMessage) ? DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS : DEFAULT_STATUS_NOTIFICATION_TIMEOUT_SECONDS;
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "", "Notify");
@@ -42,7 +47,7 @@ void FreeDesktopNotifier::showMessage(Type type, const String& subject, const St
msg << quint32(0); // ID of previous notification to replace
msg << imageScaler.getScaledImage(picture, 48).string().c_str(); // Icon to display
msg << P2QSTRING(subject); // Summary / Header of the message to display
- msg << P2QSTRING(description); // Body of the message to display
+ msg << body; // Body of the message to display
msg << actions; // Actions from which the user may choose
msg << hints; // Hints to the server displaying the message
msg << qint32(timeout*1000); // Timeout in milliseconds