Leading and trailing whitespaces are now trimmed when requesting a new custom collection name.

This commit is contained in:
Leon Styhre 2021-09-21 22:15:42 +02:00
parent e507335923
commit 527b9321b5

View file

@ -554,6 +554,15 @@ std::string CollectionSystemsManager::getValidNewCollectionName(std::string inNa
{
std::string name = inName;
// Trim leading and trailing whitespaces.
name.erase(name.begin(), std::find_if(name.begin(), name.end(), [](char c) {
return !std::isspace(static_cast<unsigned char>(c));
}));
name.erase(std::find_if(name.rbegin(), name.rend(),
[](char c) { return !std::isspace(static_cast<unsigned char>(c)); })
.base(),
name.end());
if (index == 0) {
size_t remove = std::string::npos;
// Get valid name.