]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: util: add helpers for (un)escaping notes-template
authorFabian Ebner <f.ebner@proxmox.com>
Wed, 27 Apr 2022 15:41:11 +0000 (17:41 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 28 Apr 2022 11:45:53 +0000 (13:45 +0200)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
www/manager6/Utils.js

index 4611ff0fb52ce4541dceaa362e1f20637ddfad5b..08778f5c43deccf27cb751694629dcabf0eacfe7 100644 (file)
@@ -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,