Skip to content

[form-data-parser] parseFormData fails with non-ASCII filenames (e.g., Japanese, Chinese, Korean) #11032

@ysgk

Description

@ysgk

Summary

parseFormData throws FormDataParseError when processing file uploads with non-ASCII characters in the filename (e.g., Japanese: テスト画像.png).

This issue appears to have been introduced in @remix-run/headers v0.16.0 when SuperHeaders was replaced with the standard Headers class (#10911). It seems to be an unintended side effect of this change.

Affected Versions

  • @remix-run/form-data-parser >= 0.15.0
  • @remix-run/headers >= 0.16.0
  • @remix-run/multipart-parser >= 0.14.0

Error

FormDataParseError: Cannot parse form data
  cause: TypeError: Failed to execute 'append' on 'Headers': String contains non ISO-8859-1 code point.

Root Cause

In #10911, the SuperHeaders class was removed and replaced with parseRawHeaders in @remix-run/headers.

Before:

// packages/multipart-parser/src/lib/multipart.ts
import Headers from '@remix-run/headers'
this.#headers = new Headers(decoder.decode(this.#header))

After:

// packages/multipart-parser/src/lib/multipart.ts
import { parse as parseRawHeaders } from '@remix-run/headers'
this.#headers = parseRawHeaders(decoder.decode(this.#header))

Steps to Reproduce

  1. Create a file upload form
  2. Upload a file with a non-ASCII filename (e.g., テスト画像.png, 文件.png, 파일.png)
  3. Use parseFormData(request) to parse the request
  4. Observe FormDataParseError

Expected Behavior

parseFormData should successfully parse file uploads with non-ASCII filenames.

Actual Behavior

parseFormData throws FormDataParseError with cause TypeError: Failed to execute 'append' on 'Headers': String contains non ISO-8859-1 code point.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions