GUACAMOLE-926: Trim spaces from user and user group names before importing.

This commit is contained in:
James Muehlner
2023-05-10 22:06:27 +00:00
parent 353bccb4bc
commit 6c1ac0b008

View File

@@ -456,19 +456,35 @@ angular.module('import').factory('connectionParseService',
// Ensure that the specified user list, if any, is an array // Ensure that the specified user list, if any, is an array
const users = connection.users; const users = connection.users;
if (users && !Array.isArray(users)) if (users) {
connection.errors.push(new ParseError({
message: 'Invalid users list - must be an array',
key: 'IMPORT.ERROR_INVALID_USERS_TYPE'
}));
// Ensure that the specified user list, if any, is an array // Ensure all users in the array are trimmed strings
if (Array.isArray(users))
connection.users = users.map(user => String(user).trim());
else
connection.errors.push(new ParseError({
message: 'Invalid users list - must be an array',
key: 'IMPORT.ERROR_INVALID_USERS_TYPE'
}));
}
// Ensure that the specified user group list, if any, is an array
const groups = connection.groups; const groups = connection.groups;
if (groups && !Array.isArray(groups)) if (groups) {
connection.errors.push(new ParseError({
message: 'Invalid groups list - must be an array', // Ensure all groups in the array are trimmed strings
key: 'IMPORT.ERROR_INVALID_USER_GROUPS_TYPE' if (Array.isArray(groups))
})); connection.groups = groups.map(group => String(group).trim());
else
connection.errors.push(new ParseError({
message: 'Invalid groups list - must be an array',
key: 'IMPORT.ERROR_INVALID_USER_GROUPS_TYPE'
}));
}
// If the protocol is not valid, there's no point in trying to check // If the protocol is not valid, there's no point in trying to check
// parameter case sensitivity // parameter case sensitivity