]> source.dussan.org Git - nextcloud-server.git/commitdiff
Limit size of properties to 2048 characters 26542/head
authorLukas Reschke <lukas@statuscode.ch>
Tue, 13 Apr 2021 15:24:20 +0000 (15:24 +0000)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 29 Apr 2021 18:45:11 +0000 (20:45 +0200)
It is unreasonable to expect that one of these fields would be longer
than 2048 characters. Whilst some have definitely lower limits (such as
for phone numbers or domain names), a upper bound as sanity check makes
sense.

Backport of https://github.com/nextcloud/server/pull/26433

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
lib/private/Accounts/AccountManager.php

index 1f23e7e33a360705ecb33689b8f86b86d9cc6e8d..24adeaeb3acb8415e72fdd24609a19f291bf7d67 100644 (file)
@@ -93,6 +93,14 @@ class AccountManager implements IAccountManager {
        public function updateUser(IUser $user, $data) {
                $userData = $this->getUser($user);
                $updated = true;
+
+               // set a max length
+               foreach ($data as $propertyName => $propertyData) {
+                       if (isset($data[$propertyName]) && isset($data[$propertyName]['value']) && strlen($data[$propertyName]['value']) > 2048) {
+                               $data[$propertyName]['value'] = '';
+                       }
+               }
+
                if (empty($userData)) {
                        $this->insertNewUser($user, $data);
                } elseif ($userData !== $data) {