From 99923b7b8f67b3d82df069db032611430443262d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 3 Apr 2017 20:30:05 +0100 Subject: [PATCH 1/2] Escape HTML tags in Notifications (Linux) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index c10f2f83c0..ce14a22e32 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -81,6 +81,15 @@ export default class ElectronPlatform extends VectorBasePlatform { } displayNotification(title: string, msg: string, avatarUrl: string, room: Object): Notification { + + // GNOME notification spec parses HTML tags for styling... + // Electron Docs state all supported linux notification systems follow this markup spec + // https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#linux + // maybe we should pass basic styling (italics, bold, underline) through from MD + if (window.process.platform === 'linux') { + msg = msg.replace(//g, ">"); + } + // Notifications in Electron use the HTML5 notification API const notification = new global.Notification( title, From 0da6ca8aead4b81289122118ca60e5d0a1759083 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 22 Apr 2017 16:05:08 +0100 Subject: [PATCH 2/2] add more comment to explain this weirdness Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index ce14a22e32..1271c8a551 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -86,6 +86,8 @@ export default class ElectronPlatform extends VectorBasePlatform { // Electron Docs state all supported linux notification systems follow this markup spec // https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#linux // maybe we should pass basic styling (italics, bold, underline) through from MD + // we only have to strip out < and > as the spec doesn't include anything about things like & + // so we shouldn't assume that all implementations will treat those properly. Very basic tag parsing is done. if (window.process.platform === 'linux') { msg = msg.replace(//g, ">"); }