Skip to content

Fix 3 bugs: no-arg redirect, cookie option leak, view render context.#7273

Open
Mohammad-Faiz-Cloud-Engineer wants to merge 1 commit into
expressjs:masterfrom
Mohammad-Faiz-Cloud-Engineer:master
Open

Fix 3 bugs: no-arg redirect, cookie option leak, view render context.#7273
Mohammad-Faiz-Cloud-Engineer wants to merge 1 commit into
expressjs:masterfrom
Mohammad-Faiz-Cloud-Engineer:master

Conversation

@Mohammad-Faiz-Cloud-Engineer
Copy link
Copy Markdown

@Mohammad-Faiz-Cloud-Engineer Mohammad-Faiz-Cloud-Engineer commented May 21, 2026

Found a few things that needed fixing:

  1. res.redirect() with no args - if you call it without a URL, it'd redirect to the literal string "undefined". The deprecation warning was there but didn't stop it from doing something broken. Added a safe fallback to '/'.

  2. res.cookie() leaked opts.signed - the signed property was being read from options but never cleaned up before passing the whole object to cookie.serialize(). The cookie package ignores unknown keys so it works today, but it's a leak waiting to bite if that ever changes.

  3. View.prototype.render inconsistent this - the sync and async paths used different this values when calling back. Both come from wherever the template engine sets it, but they could differ between the first call and subsequent calls. Unified it so both paths use the same captured context.

While digging through the response and view code, found a few things that needed fixing:

1. res.redirect() with no args - if you call it without a URL, it'd redirect to the literal string "undefined". The deprecation warning was there but didn't stop it from doing something broken. Added a safe fallback to '/'.

2. res.cookie() leaked opts.signed - the signed property was being read from options but never cleaned up before passing the whole object to cookie.serialize(). The cookie package ignores unknown keys so it works today, but it's a leak waiting to bite if that ever changes.

3. View.prototype.render inconsistent this - the sync and async paths used different this values when calling back. Both come from wherever the template engine sets it, but they could differ between the first call and subsequent calls. Unified it so both paths use the same captured context.
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