fix(codeapi): add UTF-8 charset defaults to busboy in upload routes - #65
Open
chottokun wants to merge 1 commit into
Open
fix(codeapi): add UTF-8 charset defaults to busboy in upload routes#65chottokun wants to merge 1 commit into
chottokun wants to merge 1 commit into
Conversation
The /upload and /upload/batch endpoints in router.ts construct busboy without specifying defCharset or defParamCharset. Busboy defaults to Latin-1 (ISO-8859-1) for multipart parameter decoding, which causes non-ASCII filenames (e.g. Japanese characters) to be garbled. file-server.ts already sets defCharset: 'utf8' and defParamCharset: 'utf8' (lines 336-337), but router.ts was missing the same options — an asymmetry that surfaces as mojibake when uploading files with non-ASCII names through the API gateway. Add both options to the two busboy() calls in router.ts for consistency with file-server.ts.
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.
Problem
Non-ASCII filenames (e.g. Japanese characters like
日本語テスト.md) uploadedthrough the
/uploadand/upload/batchendpoints are garbled becausebusboydefaults toLatin-1(ISO-8859-1) for parameter charset decoding.For example,
日本語becomes日本語.Root Cause
The
file-server.tsalready setsdefCharset: 'utf8'anddefParamCharset: 'utf8'when constructing busboy (line 336-337), butthe same options are missing from the two
busboy()calls inrouter.ts:/uploadendpoint (line ~365)/upload/batchendpoint (line ~575)This asymmetry causes filenames to be correctly decoded in the file-server
path but garbled in the API gateway upload path.
Fix
Add
defCharset: 'utf8'anddefParamCharset: 'utf8'to bothbusboy()calls in
router.ts, consistent with the existingfile-server.tsconfiguration.Testing
Verified by uploading files with Japanese filenames (e.g.
Github_Code_Reviewer_日本語_-saved.md)through the
/uploadendpoint and confirming the filename is correctly preserved without garbling.Changes
service/src/service/router.ts: AddeddefCharset: 'utf8'anddefParamCharset: 'utf8'to 2 busboy constructor calls