[pve-devel] [PATCH v4 manager 2/7] ui: util: add helpers for (un)escaping notes-template

Fabian Ebner f.ebner at proxmox.com
Wed Apr 27 17:41:11 CEST 2022


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 www/manager6/Utils.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 4611ff0f..08778f5c 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1784,6 +1784,22 @@ Ext.define('PVE.Utils', {
 
 	return undefined;
     },
+
+    escapeNotesTemplate: function(value) {
+	let replace = {
+	    '\\': '\\\\',
+	    '\n': '\\n',
+	};
+	return value.replace(/(\\|[\n])/g, match => replace[match]);
+    },
+
+    unEscapeNotesTemplate: function(value) {
+	let replace = {
+	    '\\\\': '\\',
+	    '\\n': '\n',
+	};
+	return value.replace(/(\\\\|\\n)/g, match => replace[match]);
+    },
 },
 
     singleton: true,
-- 
2.30.2






More information about the pve-devel mailing list