Skip to content

Commit 5d81e74

Browse files
authored
Merge pull request nextcloud#53590 from nextcloud/fix/files-sharing-label
fix(files_sharing): do not double escape the share title
2 parents f314d93 + 192a123 commit 5d81e74

11 files changed

Lines changed: 71 additions & 26 deletions

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,14 @@
223223
</template>
224224

225225
<script>
226+
import { showError, showSuccess } from '@nextcloud/dialogs'
226227
import { emit } from '@nextcloud/event-bus'
228+
import { t } from '@nextcloud/l10n'
229+
import moment from '@nextcloud/moment'
227230
import { generateUrl, getBaseUrl } from '@nextcloud/router'
228-
import { showError, showSuccess } from '@nextcloud/dialogs'
229231
import { ShareType } from '@nextcloud/sharing'
230-
import VueQrcode from '@chenfengyuan/vue-qrcode'
231-
import moment from '@nextcloud/moment'
232232
233+
import VueQrcode from '@chenfengyuan/vue-qrcode'
233234
import NcActionButton from '@nextcloud/vue/components/NcActionButton'
234235
import NcActionCheckbox from '@nextcloud/vue/components/NcActionCheckbox'
235236
import NcActionInput from '@nextcloud/vue/components/NcActionInput'
@@ -258,7 +259,7 @@ import GeneratePassword from '../utils/GeneratePassword.ts'
258259
import Share from '../models/Share.ts'
259260
import SharesMixin from '../mixins/SharesMixin.js'
260261
import ShareDetails from '../mixins/ShareDetails.js'
261-
import { getLoggerBuilder } from '@nextcloud/logger'
262+
import logger from '../services/logger.ts'
262263
263264
export default {
264265
name: 'SharingEntryLink',
@@ -313,10 +314,6 @@ export default {
313314
314315
ExternalLegacyLinkActions: OCA.Sharing.ExternalLinkActions.state,
315316
ExternalShareActions: OCA.Sharing.ExternalShareActions.state,
316-
logger: getLoggerBuilder()
317-
.setApp('files_sharing')
318-
.detectUser()
319-
.build(),
320317
321318
// tracks whether modal should be opened or not
322319
showQRCode: false,
@@ -330,33 +327,35 @@ export default {
330327
* @return {string}
331328
*/
332329
title() {
330+
const l10nOptions = { escape: false /* no escape as this string is already escaped by Vue */ }
331+
333332
// if we have a valid existing share (not pending)
334333
if (this.share && this.share.id) {
335334
if (!this.isShareOwner && this.share.ownerDisplayName) {
336335
if (this.isEmailShareType) {
337336
return t('files_sharing', '{shareWith} by {initiator}', {
338337
shareWith: this.share.shareWith,
339338
initiator: this.share.ownerDisplayName,
340-
})
339+
}, l10nOptions)
341340
}
342341
return t('files_sharing', 'Shared via link by {initiator}', {
343342
initiator: this.share.ownerDisplayName,
344-
})
343+
}, l10nOptions)
345344
}
346345
if (this.share.label && this.share.label.trim() !== '') {
347346
if (this.isEmailShareType) {
348347
if (this.isFileRequest) {
349348
return t('files_sharing', 'File request ({label})', {
350349
label: this.share.label.trim(),
351-
})
350+
}, l10nOptions)
352351
}
353352
return t('files_sharing', 'Mail share ({label})', {
354353
label: this.share.label.trim(),
355-
})
354+
}, l10nOptions)
356355
}
357356
return t('files_sharing', 'Share link ({label})', {
358357
label: this.share.label.trim(),
359-
})
358+
}, l10nOptions)
360359
}
361360
if (this.isEmailShareType) {
362361
if (!this.share.shareWith || this.share.shareWith.trim() === '') {
@@ -391,6 +390,7 @@ export default {
391390
}
392391
return null
393392
},
393+
394394
passwordExpirationTime() {
395395
if (this.share.passwordExpirationTime === null) {
396396
return null
@@ -613,7 +613,7 @@ export default {
613613
* @param {boolean} shareReviewComplete if the share was reviewed
614614
*/
615615
async onNewLinkShare(shareReviewComplete = false) {
616-
this.logger.debug('onNewLinkShare called (with this.share)', this.share)
616+
logger.debug('onNewLinkShare called (with this.share)', this.share)
617617
// do not run again if already loading
618618
if (this.loading) {
619619
return
@@ -628,15 +628,15 @@ export default {
628628
shareDefaults.expiration = this.formatDateToString(this.config.defaultExpirationDate)
629629
}
630630
631-
this.logger.debug('Missing required properties?', this.enforcedPropertiesMissing)
631+
logger.debug('Missing required properties?', this.enforcedPropertiesMissing)
632632
// Do not push yet if we need a password or an expiration date: show pending menu
633633
// A share would require a review for example is default expiration date is set but not enforced, this allows
634634
// the user to review the share and remove the expiration date if they don't want it
635635
if ((this.sharePolicyHasEnforcedProperties && this.enforcedPropertiesMissing) || this.shareRequiresReview(shareReviewComplete === true)) {
636636
this.pending = true
637637
this.shareCreationComplete = false
638638
639-
this.logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')
639+
logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')
640640
641641
// ELSE, show the pending popovermenu
642642
// if password default or enforced, pre-fill with random one
@@ -664,13 +664,13 @@ export default {
664664
// if the share is valid, create it on the server
665665
if (this.checkShare(this.share)) {
666666
try {
667-
this.logger.info('Sending existing share to server', this.share)
667+
logger.info('Sending existing share to server', this.share)
668668
await this.pushNewLinkShare(this.share, true)
669669
this.shareCreationComplete = true
670-
this.logger.info('Share created on server', this.share)
670+
logger.info('Share created on server', this.share)
671671
} catch (e) {
672672
this.pending = false
673-
this.logger.error('Error creating share', e)
673+
logger.error('Error creating share', e)
674674
return false
675675
}
676676
return true
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*!
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import type { User } from "@nextcloud/cypress"
7+
import { createShare } from "./FilesSharingUtils"
8+
import { createLinkShare, openLinkShareDetails } from "./PublicShareUtils"
9+
10+
describe('files_sharing: sidebar tab', () => {
11+
let alice: User
12+
13+
beforeEach(() => {
14+
cy.createRandomUser()
15+
.then((user) => {
16+
alice = user
17+
cy.mkdir(user, '/test')
18+
cy.login(user)
19+
cy.visit('/apps/files')
20+
})
21+
})
22+
23+
/**
24+
* Regression tests of https://github.com/nextcloud/server/issues/53566
25+
* Where the ' char was shown as &#39;
26+
*/
27+
it('correctly lists shares by label with special characters', () => {
28+
createLinkShare({ user: alice }, 'test')
29+
openLinkShareDetails(0)
30+
cy.findByRole('textbox', { name: /share label/i })
31+
.should('be.visible')
32+
.type('Alice\' share')
33+
34+
cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('PUT')
35+
cy.findByRole('button', { name: /update share/i }).click()
36+
cy.wait('@PUT')
37+
38+
// see the label is shown correctly
39+
cy.findByRole('list', { name: /link shares/i })
40+
.findAllByRole('listitem')
41+
.should('have.length', 1)
42+
.first()
43+
.should('contain.text', 'Share link (Alice\' share)')
44+
})
45+
})

dist/7701-7701.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/7701-7701.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/7701-7701.js.map.license

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/8708-8708.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/8708-8708.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/8708-8708.js.map.license

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8708-8708.js.license

dist/files_sharing-files_sharing_tab.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)