GUACAMOLE-926: Ensure that parameters and attributes are cast to strings.

This commit is contained in:
James Muehlner
2023-05-08 22:48:14 +00:00
parent ea6aa49a13
commit 55d874bcaa

View File

@@ -477,9 +477,17 @@ angular.module('import').factory('connectionParseService',
_.forEach(connection.parameters, (value, name) => { _.forEach(connection.parameters, (value, name) => {
// An explicit null value for a parameter is valid - do not
// process it further
if (value === null)
return;
// All non-null connection parameters must be strings.
const stringValue = String(value);
// Convert the provided value to the format that would match // Convert the provided value to the format that would match
// the lookup object format // the lookup object format
const comparisonValue = value.toLowerCase().trim(); const comparisonValue = stringValue.toLowerCase().trim();
// The validated / corrected option value for this connection // The validated / corrected option value for this connection
// parameter, if any // parameter, if any
@@ -491,6 +499,22 @@ angular.module('import').factory('connectionParseService',
if (validOptionValue) if (validOptionValue)
connection.parameters[name] = validOptionValue; connection.parameters[name] = validOptionValue;
// Even if no option is found, the value must be a string
else
connection.parameters[name] = stringValue;
});
_.forEach(connection.attributes, (value, name) => {
// An explicit null value for an attribute is valid - do not
// process it further
if (value === null)
return;
// All non-null connection attributes must be strings
connection.attributes[name] = String(value);
}); });
return connection; return connection;