Skip to content
Myr

escape res.redirect() link

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 4892305 · Browse files · 2 files+19 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+19 added−1 removed

  • tests:+17 added−0 removed
  • other:+2 added−1 removed

2 files+19 added−1 removed

modified:lib/response.js+2 added-1 removed
619 unmodified lines
620 body = statusCodes[status] + '. Redirecting to ' + url;621 },622623 html: function(){624 var u = utils.escape(url);624 body = '<p>' + statusCodes[status] + '. Redirecting to <a href="' + url + '">' + url + '</a></p>';625 body = '<p>' + statusCodes[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>';626 },627628 default: function(){629 body = '';
49 unmodified lines
modified:test/res.redirect.js+17 added
230 unmodified lines
231 res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="http://google.com">http://google.com</a></p>');232 done();233 })234 })235236 it('should escape the url', function(done){237 var app = express();238239 app.use(function(req, res){240 res.redirect('<lame>');241 });242243 request(app)244 .get('/')245 .set('Host', 'http://example.com')246 .set('Accept', 'text/html')247 .end(function(err, res){248 res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="//http://example.com/&lt;lame&gt;">//http://example.com/&lt;lame&gt;</a></p>');249 done();250 })251 })252 })253 254 describe('when accepting text', function(){255 it('should respond with text', function(done){
40 unmodified lines