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

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Location"] #24047

Closed
saftsoppa opened this issue Apr 14, 2021 · 2 comments · Fixed by #33763
Closed

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Location"] #24047

saftsoppa opened this issue Apr 14, 2021 · 2 comments · Fixed by #33763
Labels
Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@saftsoppa
Copy link

What version of Next.js are you using?

10.1.3

What version of Node.js are you using?

15.14.0

What browser are you using?

Chrome, Firefox

What operating system are you using?

macOS

How are you deploying your application?

Other platform

Describe the Bug

While redirecting, application responds with Internal Server Error when sending request with invalid characters in query key.

Expected Behavior

Normal redirect is performed

To Reproduce

  1. Send the request.
    If trailingSlash is enabled, curl "http://localhost:3000/anypath?%E2%80%9D"
    If trailingSlash is not enabled, curl "http://localhost:3000/anypath/?%E2%80%9D"

  2. Internal Server Error is returned
    https://nodejs.org/api/http.html#http_response_setheader_name_value

Attempting to set a header field name or value that contains invalid characters will result in a TypeError being thrown.

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Location"]
    at ServerResponse.setHeader (node:_http_outgoing:576:3)
    at Object.fn (/node_modules/next/next-server/server/next-server.ts:893:19)
    at Router.execute (/node_modules/next/next-server/server/router.ts:342:40)
    at DevServer.run (/node_modules/next/next-server/server/next-server.ts:1227:41)
    at DevServer.run (/node_modules/next/server/next-dev-server.ts:419:18)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at DevServer.handleRequest (/node_modules/next/next-server/server/next-server.ts:573:14) {
  code: 'ERR_INVALID_CHAR'
}
@ryok90

This comment has been minimized.

@balazsorban44 balazsorban44 added Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. kind: bug and removed bug Issue was opened via the bug report template. labels Jan 27, 2022
timneutkens added a commit to timneutkens/next.js that referenced this issue Jan 28, 2022
@kodiakhq kodiakhq bot closed this as completed in #33763 Jan 28, 2022
kodiakhq bot pushed a commit that referenced this issue Jan 28, 2022
Fixes the merge conflicts in #27003

Fixes #24977
Fixes #24047
Closes #27003

Co-Authored-By: Jamie <[email protected]>



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
Fixes the merge conflicts in vercel#27003

Fixes vercel#24977
Fixes vercel#24047
Closes vercel#27003

Co-Authored-By: Jamie <[email protected]>



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
3 participants