From 033b54934bbf10663228ced5d2c711152e1c3b43 Mon Sep 17 00:00:00 2001 From: nfebe Date: Mon, 6 Oct 2025 16:05:52 +0100 Subject: [PATCH] fix(files_sharing): Only send password on change The password param should never be sent if the intention is not remove it or update it. This commit adapts the frontend and backend to this rule to avoid weird bugs especially around updating new shares. Signed-off-by: nfebe --- .../lib/Controller/ShareAPIController.php | 11 +++++++---- apps/files_sharing/src/mixins/SharesMixin.js | 4 +++- apps/files_sharing/src/views/SharingDetailsTab.vue | 12 ++++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index c2f07b92b8a..37aa26ac475 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1339,10 +1339,13 @@ class ShareAPIController extends OCSController { $share->setPermissions($permissions); } - if ($password === '') { - $share->setPassword(null); - } elseif ($password !== null) { - $share->setPassword($password); + $passwordParamSent = $password !== null; + if ($passwordParamSent) { + if ($password === '') { + $share->setPassword(null); + } else { + $share->setPassword($password); + } } if ($label !== null) { diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js index 2dffad2ea9e..3f876ab3dc8 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -320,7 +320,9 @@ export default { // share api controller accepts for (const name of propertyNames) { if (name === 'password') { - properties[name] = this.share.newPassword ?? this.share.password + if (this.share.newPassword !== undefined) { + properties[name] = this.share.newPassword + } continue } diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue index ac06e5ce052..c0e9ccbdc58 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -976,7 +976,11 @@ export default { }, async saveShare() { const permissionsAndAttributes = ['permissions', 'attributes', 'note', 'expireDate'] - const publicShareAttributes = ['label', 'password', 'hideDownload'] + const publicShareAttributes = ['label', 'hideDownload'] + // Only include password if it's being actively changed + if (this.hasUnsavedPassword) { + publicShareAttributes.push('password') + } if (this.config.allowCustomTokens) { publicShareAttributes.push('token') } @@ -1139,7 +1143,11 @@ export default { * "sendPasswordByTalk". */ onPasswordProtectedByTalkChange() { - this.queueUpdate('sendPasswordByTalk', 'password') + if (this.isEmailShareType || this.hasUnsavedPassword) { + this.queueUpdate('sendPasswordByTalk', 'password') + } else { + this.queueUpdate('sendPasswordByTalk') + } }, isValidShareAttribute(value) { if ([null, undefined].includes(value)) {