[Bug]: Uploaded files are saved with garbled non-ASCII names and overwrite existing files with the same name
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- nodejs, typescript
- Domain
- backend
Research direction
Start in src/server/signalling/handlers/fileShare.ts, where parseMultipart decodes the part headers as latin1 and handleFileUpload calls writeFile on the sanitized name. Reproduce by posting a multipart form with résumé.pdf and a repeated image.jpg through Node's FormData, as the issue describes. Done means the UTF-8 name is saved intact and a second same-name upload is kept as image (1).jpg rather than overwriting the first; a new test file for the upload handler should cover both cases.
Written by the indexing model from the issue text.
Description
Bug Description
Files sent from the phone with Send File don't always end up on the host the way they were sent:
-
Non-ASCII file names are garbled.
résumé.pdfis saved asrésumé.pdf, and照片.jpgasç§ç.jpg. Browsers send the multipartfilenameas raw UTF-8, butparseMultipartinsrc/server/signalling/handlers/fileShare.tsreads the part headers frombody.toString("binary")(latin1), so every multi-byte character turns into mojibake. -
Uploading a file with an existing name silently overwrites the old one.
handleFileUploadcallsfs.promises.writeFile(path.join(uploadDir, safeName), data), which replaces whatever is already there. This is easy to hit from a phone: iOS Safari names every camera photoimage.jpg, so sending two photos leaves only the second one inReinShared, with no warning.
Steps to Reproduce
- Run Rein and open the trackpad page on a phone.
- Send a file named
résumé.pdfvia Send File → it appears in~/Downloads/ReinSharedasrésumé.pdf. - Send a photo from the iOS camera roll (
image.jpg), then send a different one → only oneimage.jpgexists, containing the second photo.
I also reproduced both against handleFileUpload directly with a local HTTP server and Node's FormData (which encodes file names the same way browsers do):
on disk: [ 'image.jpg', 'résumé.pdf', 'ç§ç.jpg' ]
image.jpg contents: second photo
Expected Behavior
- The file is saved with the exact name it was sent with.
- If a file with that name already exists, the new one is saved next to it (e.g.
image (1).jpg) instead of replacing it.
Desktop Operating System
All (the logic is in the platform-independent fileShare.ts)
Client OS and browser
All (any browser sends UTF-8 filenames; iOS Safari's image.jpg naming makes the overwrite very common)
Rein Version
main @ 4efa9a8
Proposed fix
- Decode the part header bytes as UTF-8 (
body.subarray(headerStart, headerEnd).toString("utf8")). The latin1 string is still fine for finding offsets, since its indices match byte positions. - Write with the
wxflag and fall back toname (1).ext,name (2).ext, … onEEXIST, which also avoids two simultaneous uploads racing for the same name. - Add a test file for the upload handler covering both cases.
I'd like to work on this.
- Dominant language
- TypeScript
- Stars
- 55
- Forks
- 120
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/Rein
-
[Bug]: JSON body null returns 500 on /api/clipboard/copy and /api/clipboard/pastePossibly taken A pull request linked to this issue is open or already merged. Openbug enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AOSSIE-Org/Rein#522 · 1 comment ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AOSSIE-Org/Rein#509 · 3 comments ·
Maintainers usually reply within 2 days
-
[Bug]: Session tokens expire 10 days after creation regardless of use (touchToken is never called)Possibly taken @Ankitavasudev claimed this 12 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
AOSSIE-Org/Rein#466 · 6 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
[Bug]: Missing WebRTC playoutDelayHint introduces 50-100ms artificial latency and redundant MediaStream recreation triggers video pipeline reloadPossibly taken @MPoojaSiyag claimed this 1 day ago. Openbug enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
AOSSIE-Org/Rein#523 · 1 comment ·
Maintainers usually reply within 2 days
-
[Bug]: release held keys, mouse buttons, and gamepad buttons on session disconnectPossibly taken @Abfa41 claimed this 4 days ago. Openbug enhancement
Difficulty 3/5 Half a day Newbie friendliness 55/100
AOSSIE-Org/Rein#518 · 1 comment ·
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
review-followup
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
griffinwork40/agent-afk#5387 ·
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CodeManufactoryLLC/Code60#358 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
android:plan ios:plan main:plan packages:learn
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day