Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get garbled code in Server actions if formdata contains not latin1 characters #70335

Open
jaredhan418 opened this issue Sep 23, 2024 · 2 comments · May be fixed by #70348
Open

Get garbled code in Server actions if formdata contains not latin1 characters #70335

jaredhan418 opened this issue Sep 23, 2024 · 2 comments · May be fixed by #70348
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@jaredhan418
Copy link

jaredhan418 commented Sep 23, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/sleepy-lamport-go8s7s

To Reproduce

1.create a new file with filename a filename with Chinese-你好世界;
2.select in file input;
3.submit form;
4. the response filename is a filename with Chinese-你好世界

Current vs. Expected behavior

Expect get same file name.
and I found the root cause is here

const busboy = (require('busboy') as typeof import('busboy'))({

The busboy default defParamCharset is latin1, if I submit chinese or other language with character not in latin1, the filename will garbled.
https://github.com/mscdex/busboy?tab=readme-ov-file#exports

But if I create an API with Route, I can use req.formdata() then the filename is correct.

Also, I tried
截屏2024-09-23 12 03 36
this config, then I can get correct filename with busboy, is that possible to set utf-8 to keep same behavior like Body.formdata()?

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 20.17.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.13 // Latest available version is detected (14.2.13).
  eslint-config-next: 14.2.13
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Not sure, Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

This issue exist in v14 and v15 canary.

@jaredhan418 jaredhan418 added the bug Issue was opened via the bug report template. label Sep 23, 2024
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Sep 23, 2024
@jaredhan418
Copy link
Author

jaredhan418 commented Sep 23, 2024

How can I config busboy under nextjs server action?

@jaredhan418
Copy link
Author

jaredhan418 commented Sep 23, 2024

@naaa760 Please don't use AI Tools fill useless suggestion and pollution this issue, thx

@jaredhan418 jaredhan418 linked a pull request Sep 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant