Skip to content

Trim whitespace in forwarded host parsing#7291

Open
raashish1601 wants to merge 1 commit into
expressjs:masterfrom
raashish1601:spark/fix-forwarded-host-trim
Open

Trim whitespace in forwarded host parsing#7291
raashish1601 wants to merge 1 commit into
expressjs:masterfrom
raashish1601:spark/fix-forwarded-host-trim

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

Fix req.host to consistently trim whitespace from X-Forwarded-Host when trust proxy is enabled.

Changes

  • lib/request.js: trim X-Forwarded-Host in both comma-separated and single-value cases.
  • test/req.host.js: add regression test for spaced host header.

Validation

  • npm test -- test/req.host.js
  • npx mocha --require test/support/env test/req.host.js

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.

1 participant