mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-30 12:43:59 -06:00
ELECTRON-426 (Only first character of room name displays for the toast of room starting with '<" or '>' character) (#344)
- Fixes html content in the notification title - Removes 'replaceStrongTag' and 'replaceHTMLTags' function and changing to innerHTML to innerText
This commit is contained in:
parent
082575e22d
commit
25772f1141
@ -116,10 +116,10 @@ function setContents(event, notificationObj) {
|
||||
}
|
||||
|
||||
// Title
|
||||
titleDoc.innerHTML = notificationObj.title || '';
|
||||
titleDoc.innerText = notificationObj.title || '';
|
||||
|
||||
// message
|
||||
messageDoc.innerHTML = notificationObj.text || '';
|
||||
messageDoc.innerText = notificationObj.text || '';
|
||||
|
||||
// Image
|
||||
if (notificationObj.image) {
|
||||
@ -130,7 +130,7 @@ function setContents(event, notificationObj) {
|
||||
|
||||
// Company
|
||||
if (notificationObj.company) {
|
||||
companyDoc.innerHTML = notificationObj.company
|
||||
companyDoc.innerText = notificationObj.company
|
||||
} else {
|
||||
messageDoc.style.marginTop = '15px';
|
||||
}
|
||||
|
@ -33,10 +33,7 @@ class Notify {
|
||||
let emitter = new EventEmitter();
|
||||
this.emitter = Queue(emitter);
|
||||
|
||||
// Replace strong html tags from the options.body
|
||||
let message = replaceStrongTag(options.body);
|
||||
// Replaces all html angle brackets w.r.t their entity name
|
||||
message = replaceHTMLTags(message);
|
||||
let message = options.body;
|
||||
|
||||
this._id = notify({
|
||||
title: title,
|
||||
@ -246,44 +243,4 @@ function Queue(emitter) {
|
||||
return modifiedEmitter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace HTML tags <> from messages test to prevent
|
||||
* HTML injection
|
||||
*
|
||||
* @param message {String} main text to display in notifications
|
||||
* @return {void | string | *}
|
||||
*/
|
||||
function replaceHTMLTags(message) {
|
||||
|
||||
if (typeof message !== 'string') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tagsToReplace = {
|
||||
'<': '<',
|
||||
'>': '>'
|
||||
};
|
||||
|
||||
function replaceTag(tag) {
|
||||
return tagsToReplace[tag] || tag;
|
||||
}
|
||||
|
||||
return message.replace(/[<>]/g, replaceTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace strong HTML tags from the string
|
||||
*
|
||||
* @param message {String} main text to display in notifications
|
||||
* @return {void | string | *}
|
||||
*/
|
||||
function replaceStrongTag(message) {
|
||||
|
||||
if (typeof message !== 'string') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return message.replace(/(?:<strong>)|(?:<\/strong>)+/g, '');
|
||||
}
|
||||
|
||||
module.exports = Notify;
|
||||
|
Loading…
Reference in New Issue
Block a user