ensure redirect target path is correctly encoded (#6229)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -82,7 +82,7 @@ module.exports = function redirector(attrs) {
|
|||||||
trace.logTrace('inbound', emojic.ticket, 'Named params', namedParams)
|
trace.logTrace('inbound', emojic.ticket, 'Named params', namedParams)
|
||||||
trace.logTrace('inbound', emojic.crayon, 'Query params', queryParams)
|
trace.logTrace('inbound', emojic.crayon, 'Query params', queryParams)
|
||||||
|
|
||||||
const targetPath = transformPath(namedParams)
|
const targetPath = encodeURI(transformPath(namedParams))
|
||||||
trace.logTrace('validate', emojic.dart, 'Target', targetPath)
|
trace.logTrace('validate', emojic.dart, 'Target', targetPath)
|
||||||
|
|
||||||
let urlSuffix = ask.uri.search || ''
|
let urlSuffix = ask.uri.search || ''
|
||||||
|
|||||||
@@ -121,6 +121,20 @@ describe('Redirector', function () {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should correctly encode the redirect URL', async function () {
|
||||||
|
const { statusCode, headers } = await got(
|
||||||
|
`${baseUrl}/very/old/service/hello%0Dworld.svg?foobar=a%0Db`,
|
||||||
|
{
|
||||||
|
followRedirect: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(statusCode).to.equal(301)
|
||||||
|
expect(headers.location).to.equal(
|
||||||
|
'/new/service/hello%0Dworld.svg?foobar=a%0Db'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
describe('transformQueryParams', function () {
|
describe('transformQueryParams', function () {
|
||||||
const route = {
|
const route = {
|
||||||
base: 'another/old/service',
|
base: 'another/old/service',
|
||||||
|
|||||||
Reference in New Issue
Block a user