Skip to content

Commit

Permalink
fix: template injection (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
climba03003 committed Sep 13, 2024
1 parent 66d3006 commit c522606
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,7 @@ function sendRedirect (path, options) {
}

const loc = encodeURI(collapseLeadingSlashes(options.path + '/'))
const doc = createHtmlDocument('Redirecting', 'Redirecting to <a href="' + escapeHtml(loc) + '">' +
escapeHtml(loc) + '</a>')
const doc = createHtmlDocument('Redirecting', 'Redirecting to ' + escapeHtml(loc))

const headers = {}
headers['Content-Type'] = 'text/html; charset=UTF-8'
Expand Down
4 changes: 2 additions & 2 deletions test/send.2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ test('send(file)', function (t) {
.get('/pets')
.expect('Location', '/pets/')
.expect('Content-Type', /html/)
.expect(301, />Redirecting to <a href="\/pets\/">\/pets\/<\/a></, err => t.error(err))
.expect(301, />Redirecting to \/pets\/</, err => t.error(err))
})

t.test('should respond with default Content-Security-Policy', function (t) {
Expand Down Expand Up @@ -323,7 +323,7 @@ test('send(file)', function (t) {
.get('/snow')
.expect('Location', '/snow%20%E2%98%83/')
.expect('Content-Type', /html/)
.expect(301, />Redirecting to <a href="\/snow%20%E2%98%83\/">\/snow%20%E2%98%83\/<\/a></, err => t.error(err))
.expect(301, />Redirecting to \/snow%20%E2%98%83\/</, err => t.error(err))
})
})

Expand Down

0 comments on commit c522606

Please sign in to comment.