aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2025-05-21 16:01:54 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2025-05-22 08:30:36 +0000
commit617af2f3cc78907e274abfa27033b0293e71cdec (patch)
tree284a43d791c08847e513cf91ccd248274b46b9e2
parent7a0261878ad9d392dc5bb36c7507138d303c35cd (diff)
downloadnextcloud-server-backport/52810/stable31.tar.gz
nextcloud-server-backport/52810/stable31.zip
fix: Replace the deprecated direct download link with the public DAV endpointbackport/52810/stable31
Follow-up of #48098 Signed-off-by: Louis Chemineau <louis@chmn.me>
-rw-r--r--apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php5
-rw-r--r--apps/files_sharing/tests/Controller/ShareControllerTest.php16
-rw-r--r--cypress/e2e/files_sharing/public-share/header-menu.cy.ts4
3 files changed, 15 insertions, 10 deletions
diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
index 71180acc4f1..8212785382f 100644
--- a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
+++ b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
@@ -150,10 +150,7 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider
$headerActions = [];
if ($view !== 'public-file-drop' && !$share->getHideDownload()) {
// The download URL is used for the "download" header action as well as in some cases for the direct link
- $downloadUrl = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', [
- 'token' => $token,
- 'filename' => ($shareNode instanceof File) ? $shareNode->getName() : null,
- ]);
+ $downloadUrl = $this->urlGenerator->getAbsoluteURL('/public.php/dav/files/' . $token . '/?accept=zip');
// If not a file drop, then add the download header action
$headerActions[] = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $downloadUrl, 0, (string)$shareNode->getSize());
diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php
index b13c7a7b6c5..ffd2df98df3 100644
--- a/apps/files_sharing/tests/Controller/ShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php
@@ -261,8 +261,12 @@ class ShareControllerTest extends \Test\TestCase {
['files_sharing.sharecontroller.showShare', ['token' => 'token'], 'shareUrl'],
// this share is not an image to the default preview is used
['files_sharing.PublicPreview.getPreview', ['x' => 256, 'y' => 256, 'file' => $share->getTarget(), 'token' => 'token'], 'previewUrl'],
- // for the direct link
- ['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename ], 'downloadUrl'],
+ ]);
+
+ $this->urlGenerator->expects($this->once())
+ ->method('getAbsoluteURL')
+ ->willReturnMap([
+ ['/public.php/dav/files/token/?accept=zip', 'downloadUrl'],
]);
$this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
@@ -552,8 +556,12 @@ class ShareControllerTest extends \Test\TestCase {
['files_sharing.sharecontroller.showShare', ['token' => 'token'], 'shareUrl'],
// this share is not an image to the default preview is used
['files_sharing.PublicPreview.getPreview', ['x' => 256, 'y' => 256, 'file' => $share->getTarget(), 'token' => 'token'], 'previewUrl'],
- // for the direct link
- ['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename ], 'downloadUrl'],
+ ]);
+
+ $this->urlGenerator->expects($this->once())
+ ->method('getAbsoluteURL')
+ ->willReturnMap([
+ ['/public.php/dav/files/token/?accept=zip', 'downloadUrl'],
]);
$this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
diff --git a/cypress/e2e/files_sharing/public-share/header-menu.cy.ts b/cypress/e2e/files_sharing/public-share/header-menu.cy.ts
index a89ee8eb90e..c127adc56c6 100644
--- a/cypress/e2e/files_sharing/public-share/header-menu.cy.ts
+++ b/cypress/e2e/files_sharing/public-share/header-menu.cy.ts
@@ -53,7 +53,7 @@ describe('files_sharing: Public share - header actions menu', { testIsolation: t
cy.findByRole('menuitem', { name: 'Direct link' })
.should('be.visible')
.and('have.attr', 'href')
- .then((attribute) => expect(attribute).to.match(/^http:\/\/.+\/download$/))
+ .then((attribute) => expect(attribute).to.match(new RegExp(`^${Cypress.env('baseUrl')}/public.php/dav/files/.+/?accept=zip$`)))
// see menu closes on click
cy.findByRole('menuitem', { name: 'Direct link' })
.click()
@@ -188,7 +188,7 @@ describe('files_sharing: Public share - header actions menu', { testIsolation: t
cy.findByRole('menuitem', { name: 'Direct link' })
.should('be.visible')
.and('have.attr', 'href')
- .then((attribute) => expect(attribute).to.match(/^http:\/\/.+\/download$/))
+ .then((attribute) => expect(attribute).to.match(new RegExp(`^${Cypress.env('baseUrl')}/public.php/dav/files/.+/?accept=zip$`)))
// See remote share works
cy.findByRole('menuitem', { name: /Add to your/i })
.should('be.visible')