[pve-devel] [PATCH manager 1/2] ui: cloudinit: use PVE.Parser.parseSSHKey

Lorenz Stechauner l.stechauner at proxmox.com
Fri May 14 12:13:16 CEST 2021


Signed-off-by: Lorenz Stechauner <l.stechauner at proxmox.com>
---
 www/manager6/qemu/CloudInit.js | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/www/manager6/qemu/CloudInit.js b/www/manager6/qemu/CloudInit.js
index ccd1840b..43405a67 100644
--- a/www/manager6/qemu/CloudInit.js
+++ b/www/manager6/qemu/CloudInit.js
@@ -264,13 +264,10 @@ Ext.define('PVE.qemu.CloudInit', {
 		    var text = [];
 		    keys.forEach(function(key) {
 			if (key.length) {
-			    // First erase all quoted strings (eg. command="foo"
-			    var v = key.replace(/"(?:\\.|[^"\\])*"/g, '');
-			    // Now try to detect the comment:
-			    var res = v.match(/^\s*(\S+\s+)?(?:ssh-(?:dss|rsa|ed25519)|ecdsa-sha2-nistp\d+)\s+\S+\s+(.*?)\s*$/, '');
+			    let res = PVE.Parser.parseSSHKey(key);
 			    if (res) {
-				key = Ext.String.htmlEncode(res[2]);
-				if (res[1]) {
+				key = Ext.String.htmlEncode(res.comment);
+				if (res.options) {
 				    key += ' <span style="color:gray">(' + gettext('with options') + ')</span>';
 				}
 				text.push(key);
-- 
2.20.1






More information about the pve-devel mailing list