Repository navigation
fix: export wikis whose repository name is not ASCII - #626
Merged
sng-asyncfunc merged 2 commits intoNov 8, 2026
Merged
Conversation
/export/wiki put the repository name straight into Content-Disposition. Header values are encoded as latin-1, so a local repository in a directory such as /home/user/项目 made the export fail with a 500 (UnicodeEncodeError), and a name with a space produced an unquoted filename. Send a quoted ASCII fallback in filename= and the real name in filename*=UTF-8'' (RFC 6266), and have the repo page read filename* first. Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
sashimikun
reviewed
Nov 8, 2026
sashimikun
left a comment
Contributor
There was a problem hiding this comment.
No blocking issues found in a brief review. Small test improvement: add frontend coverage for filename* taking precedence, malformed percent-encoding falling back to filename=, and a missing header keeping the default name. The new backend tests don't exercise that download-name parsing path.
Move the Content-Disposition parsing out of the export handler into src/utils/contentDisposition.ts and test it with node:test (no new dependencies): filename* precedence, malformed percent-encoding falling back to filename=, and a missing header keeping the default. Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
Contributor
Author
|
Good point, the backend tests never touched that path. I moved the header parsing into |
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.
POST /export/wikibuilds the download name from the last part ofrepo_urland sends it asContent-Disposition: attachment; filename={filename}. Starlette encodes header values as latin-1, so when the name is not latin-1 the response cannot be built and the export fails with a 500 (UnicodeEncodeError). This happens, for example, with a local repository in/home/user/项目. A name with a space (/home/user/my repo) went out unquoted.Fix
api/routers/wiki.py: a small_attachment_headerhelper sends a quoted ASCII fallback infilename=(anything outside[A-Za-z0-9._-]becomes_) and the real name percent-encoded infilename*=UTF-8''...(RFC 6266). Browsers and the repo page usefilename*.src/app/[owner]/[repo]/page.tsx: the export handler used/filename=(.+)/and would have taken everything after the firstfilename=. It now readsfilename*first (withdecodeURIComponent), falls back to the quotedfilename=and then to the existing default.ASCII names download with the same file name as before.
Tests
New
tests/backend/routers/test_wiki_export.pyposts an export for a GitHub URL,/home/user/项目and/home/user/my repo. It checks that the header is pure ASCII, has a quotedfilename=, and thatfilename*decodes to<name>_wiki_<timestamp>.md.main: 3 failed (500 for the non-ASCII name, unquotedfilename=withoutfilename*for the others)pytest tests/test_config.py tests/backend: 63 passedtsc --noEmit -p .passes.next lintcurrently fails onmainitself (FlatCompatimport in the ESLint config), so I could not run it.