fix(ocdav): encode oc:downloadURL path so filenames with "%" round-trip#653
Open
michaelstingl wants to merge 1 commit into
Open
fix(ocdav): encode oc:downloadURL path so filenames with "%" round-trip#653michaelstingl wants to merge 1 commit into
michaelstingl wants to merge 1 commit into
Conversation
downloadURL built the path with url.JoinPath, which unescapes its input, so a filename containing a literal "%" (e.g. "%20") collapsed (e.g. to a space) and the download returned 404 while the resource href stayed correct. Use net.EncodePath — the same encoder the href uses — which escapes "%"->"%25" and "#"->"%23" so reserved characters round-trip. Fixes: opencloud-eu/opencloud#2852
Member
|
Please remove the changelog item. We are using ready-release-go from woodpecker. |
f86dda6 to
3fccfa3
Compare
Author
|
@micbar done, removed the changelog commit. The fix commit is unchanged. 🤖 drafted with Claude Code, reviewed before submitting. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PROPFIND builds the
oc:downloadURLproperty withurl.JoinPath, which treats a literal%in a filename as an escape. A name likefirstword%20secondword.pdfis read asfirstword secondword.pdf, so the web "Download" button requests the wrong path and the download returns 404 from personal/space storage. The siblinghrefin the same response usesnet.EncodePathand stays correct, so PROPFIND already emits a correcthrefnext to an under-encodedoc:downloadURL.The fix uses
net.EncodePath(path), the encoder thehrefalready uses, indownloadURL(internal/http/services/owncloud/ocdav/propfind/propfind.go).url.JoinPathwas introduced here to keep a literal#working (see #415);net.EncodePathcovers both#->%23and%->%25, so it keeps that behavior while letting names with reserved characters round-trip. The GET handler and the proxy are unchanged; only the URL this property emits was wrong.Related Issue
Motivation and Context
A file whose name contains a literal
%cannot be downloaded from personal or space storage via the web UI, although it lists and opens normally. Public links are unaffected: the public-files handler resolves the file by share token and emits nooc:downloadURL.How Has This Been Tested?
main, Go 1.26, localgo build,go vet,go test ./...propfind/...and.../net/..., and the pinnedgolangci-lintv2.10.1 (make lint): all pass, 0 lint issuesDescribeTablefordownloadURLasserts a literal%encodes to%25(whether or not followed by hex digits),#to%23, a plain space to%20firstword%20secondword.pdfemits anoc:downloadURLending...firstword%2520secondword.pdfwith the fix and...firstword%20secondword.pdfwithout itScreenshots (if appropriate):
n/a. Server-side URL-encoding fix.
Types of changes
Checklist:
Type:*label via ready-release-go; no fragment needed)🤖 drafted with Claude Code, reviewed before submitting.