forked from zulip/zulip-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: zulip#554.
- Loading branch information
1 parent
73dc3db
commit 50647e3
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |