The old parsing logic utilized split with the limit parameter for
parsing key=value pairs in a property string. String.splt() doesn't
stop at splitting after `limit` occurences of the specified separator,
but rather splits the whole string and then only returns the first
'limit' parts from the result.

This leads to issues with values that contain an equals sign, since
the returned value only includes the string up until the first
occurence of an equals sign. This is particularly problematic when the
value is a base64 string, which are commonly padded by utilizing an
equals sign.

Use indexOf instead to find the first occurence of an equals sign, and
then split the property into key and value at only that index. This
allows for equals signs in values (but not keys).

Signed-off-by: Stefan Hanreich <[email protected]>
---
 www/manager6/Parser.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/www/manager6/Parser.js b/www/manager6/Parser.js
index 5e7e87df6..4676a7eca 100644
--- a/www/manager6/Parser.js
+++ b/www/manager6/Parser.js
@@ -54,7 +54,12 @@ Ext.define('PVE.Parser', {
 
             try {
                 value.split(',').forEach((property) => {
-                    let [k, v] = property.split('=', 2);
+                    let idx = property.indexOf('=');
+                    let [k, v] =
+                        idx === -1
+                            ? [property, null]
+                            : [property.substring(0, idx), 
property.substring(idx + 1)];
+
                     if (Ext.isDefined(v)) {
                         res[k] = v;
                     } else if (Ext.isDefined(defaultKey)) {
-- 
2.47.3



Reply via email to