mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	fix: change translator escape
remove \\\] and \\\[ match double ] and [
This commit is contained in:
		| @@ -463,7 +463,9 @@ module.exports = function (utils, load, warn) { | |||||||
| 		 * @returns {string} | 		 * @returns {string} | ||||||
| 		 */ | 		 */ | ||||||
| 		Translator.escape = function escape(text) { | 		Translator.escape = function escape(text) { | ||||||
| 			return typeof text === 'string' ? text.replace(/\[\[/g, '[[').replace(/\]\]/g, ']]') : text; | 			return typeof text === 'string' ? | ||||||
|  | 				text.replace(/\[\[/g, '[[').replace(/\]\]/g, ']]') : | ||||||
|  | 				text; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		/** | 		/** | ||||||
| @@ -473,8 +475,7 @@ module.exports = function (utils, load, warn) { | |||||||
| 		 */ | 		 */ | ||||||
| 		Translator.unescape = function unescape(text) { | 		Translator.unescape = function unescape(text) { | ||||||
| 			return typeof text === 'string' ? | 			return typeof text === 'string' ? | ||||||
| 				text.replace(/[/g, '[').replace(/\\\[/g, '[') | 				text.replace(/]]/g, ']]').replace(/[[/g, '[[') : | ||||||
| 					.replace(/]/g, ']').replace(/\\\]/g, ']') : |  | ||||||
| 				text; | 				text; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -308,10 +308,6 @@ describe('Translator static methods', () => { | |||||||
|  |  | ||||||
| 	describe('.unescape', () => { | 	describe('.unescape', () => { | ||||||
| 		it('should unescape escaped translation patterns within text', (done) => { | 		it('should unescape escaped translation patterns within text', (done) => { | ||||||
| 			assert.strictEqual( |  | ||||||
| 				Translator.unescape('some nice text \\[\\[global:home\\]\\] here'), |  | ||||||
| 				'some nice text [[global:home]] here' |  | ||||||
| 			); |  | ||||||
| 			assert.strictEqual( | 			assert.strictEqual( | ||||||
| 				Translator.unescape('some nice text [[global:home]] here'), | 				Translator.unescape('some nice text [[global:home]] here'), | ||||||
| 				'some nice text [[global:home]] here' | 				'some nice text [[global:home]] here' | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user