Skip to content

fix: URL-encode the S3 CopySource so attachments with non-ASCII names are copied - #2508

Merged
Philipinho merged 3 commits into
docmost:mainfrom
f1n3d:fix/duplicate-non-ascii-attachments-2010
Oct 30, 2026
Merged

Philipinho merged 3 commits into
docmost:mainfrom
f1n3d:fix/duplicate-non-ascii-attachments-2010

Conversation

@f1n3d

@f1n3d f1n3d commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

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: CopyObjectCommand sends CopySource as the x-amz-copy-source header, which must be URL-encoded. With a raw non-ASCII key the AWS SDK throws ERR_INVALID_CHAR: Invalid character in header content ["x-amz-copy-source"]. This PR encodes each path segment and keeps the / separators. The destination Key needs 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.png and my_file+plus.png:

Fixes #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

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
f1n3d force-pushed the fix/duplicate-non-ascii-attachments-2010 branch from 80a6371 to a3e4bb3 Compare September 24, 2026 08:02
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]>
@f1n3d f1n3d changed the title fix: copy attachments with non-ASCII filenames on page duplicate fix: URL-encode the S3 CopySource so attachments with non-ASCII names are copied Sep 26, 2026
- 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
@Philipinho
Philipinho merged commit fa02a90 into docmost:main Oct 30, 2026
3 checks passed
@Philipinho

Copy link
Copy Markdown
Member

Thanks for contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Duplicate page fails to copy attachments with non-ASCII filenames (e.g., Korean)

2 participants