Skip to content

fix: URL-encode filenames with special characters to prevent 404 errors#645

Merged
camathieu merged 2 commits intomasterfrom
fix/url-encoding-special-chars
Feb 25, 2026
Merged

fix: URL-encode filenames with special characters to prevent 404 errors#645
camathieu merged 2 commits intomasterfrom
fix/url-encoding-special-chars

Conversation

@camathieu
Copy link
Member

What

Properly encodes filenames with encodeURIComponent (JS) and url.PathEscape (Go) before interpolating them into URL paths across the webapp, Go SDK, and server responses.

Why

Previously, filenames containing characters like #, spaces, or parentheses were interpolated verbatim into URL paths. A filename like #test.txt would send a request to /file/ID/ID/, treating #test.txt as a URL fragment delimiter, resulting in a 404 Not Found error.

Changes

  • Webapp (api.js): Added encodeURIComponent() for uploadFile, removeFile, getFileURL, and getArchiveURL.
  • Go SDK (plik/internal.go, plik/file.go): Added url.PathEscape() for all upload, download, and remove URL constructions.
  • Server (add_file.go): Added url.PathEscape() to the quick-mode URL response. Renamed local url string variable to fileURL to prevent shadowing the net/url import.

Testing

  • Added TestUploadFileWithSpecialChars and TestQuickUploadWithSpecialChars in plik/z1_e2e_test.go to verify URL-encoding end-to-end.
  • Added uploads a file with special characters in name in webapp/e2e/upload.spec.js to verify the web UI upload flow.
  • Ran and passed full regression test suite (make test and make test-frontend-e2e).

Copy link
Member

@bodji bodji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice :)

@camathieu camathieu merged commit 3202c4a into master Feb 25, 2026
7 checks passed
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.

2 participants