Skip to content

fix(files_sharing): encode path in public share download redirect - #65983

Merged
artonge merged 1 commit into
nextcloud:masterfrom
MarioPym:fix/share-download-redirect-encoding
Nov 25, 2026
Merged

artonge merged 1 commit into
nextcloud:masterfrom
MarioPym:fix/share-download-redirect-encoding

Conversation

@MarioPym

Copy link
Copy Markdown
Contributor

Summary

The legacy public share download endpoint (/s/{token}/download?path=... and ?files=<name>) redirects to the public WebDAV URL by appending the requested node's relative path unencoded. Consequently, folder or file names containing reserved URL characters break the redirect:

  • # truncates the path into a URL fragment (e.g., downloading a#b results in /public.php/dav/files/<token>/a#b?accept=zip, causing the client to request /a and fail with a 404).
  • Other reserved characters like ? or % cause similar malformed URLs.

This fix encodes the path segment by segment using OCP\Util::encodePath() prior to generating the redirect, leaving names without special characters unaffected.

How to test

  1. Create a folder shared with a subfolder a#b containing a file, and share shared by public link.
  2. Open /index.php/s/<token>/download?path=/a%23b.
  3. Before: Location: .../public.php/dav/files/<token>/a#b?accept=zip → 404.
    After: Location: .../public.php/dav/files/<token>/a%23b?accept=zip → 200, zip with a#b/x.txt.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@MarioPym

Copy link
Copy Markdown
Contributor Author

Hi, friendly ping: could someone from the team take a look at this when there's time? CI is green except for the usual unrelated checks. Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@artonge
artonge requested review from a team, GhassenKefi and pabzm and removed request for a team November 20, 2026 10:40
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Mario Alfonso Pym Mejía <pymm@hitss.com>
@artonge
artonge force-pushed the fix/share-download-redirect-encoding branch from 55450ee to 2556b54 Compare November 25, 2026 15:06
@artonge
artonge requested a review from a team as a code owner November 25, 2026 15:06
@artonge
artonge enabled auto-merge November 25, 2026 15:06
@artonge
artonge merged commit 21c24cd into nextcloud:master Nov 25, 2026
181 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants