Repository navigation
fix: URL-encode the S3 CopySource so attachments with non-ASCII names are copied - #2508
Merged
Philipinho merged 3 commits intoOct 30, 2026
Merged
Conversation
S3 requires CopySource to be URL-encoded. The raw key broke request signing/parsing for non-ASCII filenames (e.g. Korean), spaces or '+', so duplicating a page failed exactly for those attachments while ASCII names worked. Encode CopySource per segment, preserving '/'. Also fail loudly instead of silently no-op-ing when the copy source is missing (local/s3/azure drivers), so duplicates no longer end up with dangling attachment references and a bare 404. Fixes docmost#2010
f1n3d
force-pushed
the
fix/duplicate-non-ascii-attachments-2010
branch
from
September 24, 2026 08:02
80a6371 to
a3e4bb3
Compare
The bug only affects S3: with the local driver, files with non-ASCII names are copied fine. Revert the unrelated "throw on missing source" change in the local, Azure and S3 drivers and keep only the encoding. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Build the signed URL from the blob client so non-ASCII names are percent-encoded - Cover the Azure signed URL and the S3 CopySource with specs
Member
|
Thanks for contributing. |
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.
Duplicating a page whose attachments have non-ASCII file names (e.g. Korean
스크린샷_2026-01-06.png) left broken images when S3 storage is used: the file copy failed (Duplicate page: failed to copy attachment …) while the content reference had already been rewritten.Root cause:
CopyObjectCommandsendsCopySourceas thex-amz-copy-sourceheader, which must be URL-encoded. With a raw non-ASCII key the AWS SDK throwsERR_INVALID_CHAR: Invalid character in header content ["x-amz-copy-source"]. This PR encodes each path segment and keeps the/separators. The destinationKeyneeds no encoding.The local storage driver is not affected: files with non-ASCII names are duplicated fine there.
Tested in a local dev environment with an S3-compatible backend (SeaweedFS), duplicating a page with
image.png,스크린샷_2026-01-06.pngandmy_file+plus.png:tsc --noEmitpassesFixes #2010
Transparency note: this PR was made with AI assistance. I used Claude Code to analyze the problem, adjust the code and run the tests above in a local Docmost dev environment.
🤖 Generated with Claude Code