diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index cd4bac264b41d..5a31388374377 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -27,6 +27,8 @@ #include #include +#include + #ifdef Q_OS_MAC #include #endif @@ -1498,6 +1500,17 @@ void FolderMan::editFileLocally(const QString &userId, const QString &relPath, c showError(accountFound, tr("Could not find a folder to sync."), relPath); return; } + + // Token is an alphanumeric string 128 chars long. + // Ensure that is what we received and what we are sending to the server. + const QRegularExpression tokenRegex("^[a-zA-Z0-9]{128}$"); + const auto regexMatch = tokenRegex.match(token); + + // Means invalid token type received, be cautious with bad token + if(!regexMatch.hasMatch()) { + showError(accountFound, tr("Invalid token received:"), token); + return; + } const auto relPathSplit = relPath.split(QLatin1Char('/')); if (relPathSplit.size() > 0) {