Skip to content

Commit de7d229

Browse files
nfebebackportbot[bot]
authored andcommitted
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 <fenn25.fn@gmail.com> [skip ci]
1 parent e77d8c9 commit de7d229

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,10 +1339,13 @@ public function updateShare(
13391339
$share->setPermissions($permissions);
13401340
}
13411341

1342-
if ($password === '') {
1343-
$share->setPassword(null);
1344-
} elseif ($password !== null) {
1345-
$share->setPassword($password);
1342+
$passwordParamSent = $password !== null;
1343+
if ($passwordParamSent) {
1344+
if ($password === '') {
1345+
$share->setPassword(null);
1346+
} else {
1347+
$share->setPassword($password);
1348+
}
13461349
}
13471350

13481351
if ($label !== null) {

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ export default {
320320
// share api controller accepts
321321
for (const name of propertyNames) {
322322
if (name === 'password') {
323-
properties[name] = this.share.newPassword ?? this.share.password
323+
if (this.share.newPassword !== undefined) {
324+
properties[name] = this.share.newPassword
325+
}
324326
continue
325327
}
326328

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,11 @@ export default {
976976
},
977977
async saveShare() {
978978
const permissionsAndAttributes = ['permissions', 'attributes', 'note', 'expireDate']
979-
const publicShareAttributes = ['label', 'password', 'hideDownload']
979+
const publicShareAttributes = ['label', 'hideDownload']
980+
// Only include password if it's being actively changed
981+
if (this.hasUnsavedPassword) {
982+
publicShareAttributes.push('password')
983+
}
980984
if (this.config.allowCustomTokens) {
981985
publicShareAttributes.push('token')
982986
}
@@ -1139,7 +1143,11 @@ export default {
11391143
* "sendPasswordByTalk".
11401144
*/
11411145
onPasswordProtectedByTalkChange() {
1142-
this.queueUpdate('sendPasswordByTalk', 'password')
1146+
if (this.isEmailShareType || this.hasUnsavedPassword) {
1147+
this.queueUpdate('sendPasswordByTalk', 'password')
1148+
} else {
1149+
this.queueUpdate('sendPasswordByTalk')
1150+
}
11431151
},
11441152
isValidShareAttribute(value) {
11451153
if ([null, undefined].includes(value)) {

0 commit comments

Comments
 (0)