Skip to content

Commit 4864716

Browse files
authored
Merge pull request element-hq#3564 from t3chguy/t3chguy/malformed-notifications-gnome-kde
Escape HTML Tags from Linux Notifications (electron)
2 parents 8a6283f + 0da6ca8 commit 4864716

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎src/vector/platform/ElectronPlatform.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ export default class ElectronPlatform extends VectorBasePlatform {
8181
}
8282

8383
displayNotification(title: string, msg: string, avatarUrl: string, room: Object): Notification {
84+
85+
// GNOME notification spec parses HTML tags for styling...
86+
// Electron Docs state all supported linux notification systems follow this markup spec
87+
// https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#linux
88+
// maybe we should pass basic styling (italics, bold, underline) through from MD
89+
// we only have to strip out < and > as the spec doesn't include anything about things like &amp;
90+
// so we shouldn't assume that all implementations will treat those properly. Very basic tag parsing is done.
91+
if (window.process.platform === 'linux') {
92+
msg = msg.replace(/</g, "&lt;").replace(/>/g, "&gt;");
93+
}
94+
8495
// Notifications in Electron use the HTML5 notification API
8596
const notification = new global.Notification(
8697
title,

0 commit comments

Comments
 (0)