mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-10-31 12:03:39 +00:00 
			
		
		
		
	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.
		
			
				
	
	
		
			26 lines
		
	
	
		
			436 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			436 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| '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();
 |