Skip to content

Commit 60fb1d2

Browse files
committed
Merge tag '4.19.1' into 5.x
4.19.1
2 parents e9f9aae + 4f0f6cc commit 60fb1d2

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

History.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
5.x
22
===
33

4-
This incorporates all changes after 4.17.2 up to 4.17.3.
4+
This incorporates all changes after 4.17.2 up to 4.19.1.
55

66
5.0.0-beta.1 / 2022-02-14
77
=========================
@@ -162,7 +162,12 @@ This is the first Express 5.0 alpha release, based off 4.10.1.
162162
* add:
163163
- `app.router` is a reference to the base router
164164

165-
4.18.3 / 2024-03-20
165+
4.19.1 / 2024-03-20
166+
==========
167+
168+
* Allow passing non-strings to res.location with new encoding handling checks
169+
170+
4.19.0 / 2024-03-20
166171
==========
167172

168173
* Prevent open redirect allow list bypass due to encodeurl

lib/response.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ res.cookie = function (name, value, options) {
773773
*/
774774

775775
res.location = function location(url) {
776-
var loc = url;
776+
var loc = String(url);
777777

778778
// "back" is an alias for the referrer
779779
if (url === 'back') {

test/res.location.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('res', function(){
5858
});
5959

6060
request(app)
61-
.get('/?q=http://google.com\\@apple.com')
61+
.get('/?q=http://google.com' + encodeURIComponent('\\@apple.com'))
6262
.expect(200)
6363
.expect('Location', 'http://google.com\\@apple.com')
6464
.end(function (err) {
@@ -68,7 +68,7 @@ describe('res', function(){
6868

6969
// This ensures that our protocol check is case insensitive
7070
request(app)
71-
.get('/?q=HTTP://google.com\\@apple.com')
71+
.get('/?q=HTTP://google.com' + encodeURIComponent('\\@apple.com'))
7272
.expect(200)
7373
.expect('Location', 'HTTP://google.com\\@apple.com')
7474
.end(done)
@@ -145,5 +145,20 @@ describe('res', function(){
145145
.expect(200, done)
146146
})
147147
})
148+
149+
if (typeof URL !== 'undefined') {
150+
it('should accept an instance of URL', function (done) {
151+
var app = express();
152+
153+
app.use(function(req, res){
154+
res.location(new URL('http://google.com/')).end();
155+
});
156+
157+
request(app)
158+
.get('/')
159+
.expect('Location', 'http://google.com/')
160+
.expect(200, done);
161+
});
162+
}
148163
})
149164
})

0 commit comments

Comments
 (0)