summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-04-14 22:10:15 +0200
committerGitHub <noreply@github.com>2022-04-14 22:10:15 +0200
commit07249728d46debf0d3ade50a885936535e24da85 (patch)
tree712c0cdf21843940427c8ac168560dc241df9569 /apps
parent24aae72e7e6b65458b867d42cf5f1e0d30d3b985 (diff)
parent3096179190caab8f6a871a8a9e4d2e139558f500 (diff)
downloadnextcloud-server-07249728d46debf0d3ade50a885936535e24da85.tar.gz
nextcloud-server-07249728d46debf0d3ade50a885936535e24da85.zip
Merge pull request #31678 from nextcloud/backport/31658/stable23
[stable23] Limit the length of app password names
Diffstat (limited to 'apps')
-rw-r--r--apps/settings/lib/Controller/AuthSettingsController.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/apps/settings/lib/Controller/AuthSettingsController.php b/apps/settings/lib/Controller/AuthSettingsController.php
index 3255fcce56e..38db7be1e91 100644
--- a/apps/settings/lib/Controller/AuthSettingsController.php
+++ b/apps/settings/lib/Controller/AuthSettingsController.php
@@ -145,6 +145,10 @@ class AuthSettingsController extends Controller {
return $this->getServiceNotAvailableResponse();
}
+ if (mb_strlen($name) > 128) {
+ $name = mb_substr($name, 0, 120) . '…';
+ }
+
$token = $this->generateRandomDeviceToken();
$deviceToken = $this->tokenProvider->generateToken($token, $this->uid, $loginName, $password, $name, IToken::PERMANENT_TOKEN);
$tokenData = $deviceToken->jsonSerialize();
@@ -241,6 +245,10 @@ class AuthSettingsController extends Controller {
$this->publishActivity($scope['filesystem'] ? Provider::APP_TOKEN_FILESYSTEM_GRANTED : Provider::APP_TOKEN_FILESYSTEM_REVOKED, $token->getId(), ['name' => $currentName]);
}
+ if (mb_strlen($name) > 128) {
+ $name = mb_substr($name, 0, 120) . '…';
+ }
+
if ($token instanceof INamedToken && $name !== $currentName) {
$token->setName($name);
$this->publishActivity(Provider::APP_TOKEN_RENAMED, $token->getId(), ['name' => $currentName, 'newName' => $name]);