From 55d874bcaa897bbec06e6caec0fca1180d9a6b0c Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Mon, 8 May 2023 22:48:14 +0000 Subject: [PATCH] GUACAMOLE-926: Ensure that parameters and attributes are cast to strings. --- .../import/services/connectionParseService.js | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/frontend/src/app/import/services/connectionParseService.js b/guacamole/src/main/frontend/src/app/import/services/connectionParseService.js index b7c2923ec..b7135ec22 100644 --- a/guacamole/src/main/frontend/src/app/import/services/connectionParseService.js +++ b/guacamole/src/main/frontend/src/app/import/services/connectionParseService.js @@ -477,9 +477,17 @@ angular.module('import').factory('connectionParseService', _.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 // the lookup object format - const comparisonValue = value.toLowerCase().trim(); + const comparisonValue = stringValue.toLowerCase().trim(); // The validated / corrected option value for this connection // parameter, if any @@ -491,6 +499,22 @@ angular.module('import').factory('connectionParseService', if (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;