mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-02 04:53:17 +00:00
server-name: Unescape server name in window menu item.
Escaping is necessary to avoid any security risk but we need to unescape those strings in order to show them in the frontend otherwise it will have ugly special characters. We already escape server name in the db and unesacoe it in the left-sidebar. This PR adds the decodeString function in order to unescape strings in the menu items. Fixes: #554.
This commit is contained in:
@@ -14,6 +14,8 @@ const ConfigUtil = require(__dirname + '/js/utils/config-util.js');
|
||||
const DNDUtil = require(__dirname + '/js/utils/dnd-util.js');
|
||||
const ReconnectUtil = require(__dirname + '/js/utils/reconnect-util.js');
|
||||
const Logger = require(__dirname + '/js/utils/logger-util.js');
|
||||
const CommonUtil = require(__dirname + '/js/utils/common-util.js');
|
||||
|
||||
const { feedbackHolder } = require(__dirname + '/js/feedback.js');
|
||||
|
||||
const logger = new Logger({
|
||||
@@ -177,7 +179,7 @@ class ServerManagerView {
|
||||
index,
|
||||
tabIndex,
|
||||
url: server.url,
|
||||
name: server.alias,
|
||||
name: CommonUtil.decodeString(server.alias),
|
||||
isActive: () => {
|
||||
return index === this.activeTabIndex;
|
||||
},
|
||||
|
||||
25
app/renderer/js/utils/common-util.js
Normal file
25
app/renderer/js/utils/common-util.js
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
let instance = null;
|
||||
|
||||
class CommonUtil {
|
||||
constructor() {
|
||||
if (instance) {
|
||||
return instance;
|
||||
} else {
|
||||
instance = this;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
// unescape already encoded/escaped strings
|
||||
decodeString(string) {
|
||||
const parser = new DOMParser();
|
||||
const dom = parser.parseFromString(
|
||||
'<!doctype html><body>' + string,
|
||||
'text/html');
|
||||
return dom.body.textContent;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new CommonUtil();
|
||||
Reference in New Issue
Block a user