Skip to content

fix(next/form): normalize newlines in GET submissions - #98587

Open
sohailsk0160 wants to merge 1 commit into
vercel:canaryfrom
sohailsk0160:fix/form-newline-normalization
Open

fix(next/form): normalize newlines in GET submissions#98587
sohailsk0160 wants to merge 1 commit into
vercel:canaryfrom
sohailsk0160:fix/form-newline-normalization

Conversation

@sohailsk0160

Copy link
Copy Markdown

What?

Fix next/form GET submissions so newline characters are normalized consistently with native HTML form submissions after hydration.

Why?

When a textarea was submitted through a hydrated next/form with a string action, newline characters were sent as LF (\n).

Native application/x-www-form-urlencoded GET forms normalize standalone CR and LF characters to CRLF (\r\n) before URL encoding. This caused native forms and hydrated next/form components to submit different values for identical textarea content.

How?

Normalize form entry names and string values to CRLF before appending them to the target URL's search parameters.

Existing file-input handling remains unchanged because native form submission uses the file name directly.

Added end-to-end coverage for:

  • App Router forms
  • Pages Router forms
  • Hydrated next/form submissions
  • Comparison with native form submissions
  • CRLF values in the resulting server search parameters and URL

Testing

  • Editor diagnostics: passed
  • Prettier check: passed
  • git diff --check: passed
  • Focused E2E tests could not be completed locally because the checkout was missing generated Next.js build artifacts required by the test runner.

Related Issue

Fixes #98405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

next/form does not normalize newlines in GET submissions after hydration

1 participant