Unverified Commit 28fc8944 authored by Steven's avatar Steven Committed by GitHub

fix(next/image): handle invalid url (#67465)

parent 38b34231
......@@ -213,6 +213,12 @@ export class ImageOptimizerCache {
}
}
if (url.startsWith('/_next/image')) {
return {
errorMessage: '"url" parameter cannot be recursive',
}
}
let isAbsolute: boolean
if (url.startsWith('/')) {
......
......@@ -1021,6 +1021,13 @@ export function runTests(ctx: RunTestsCtx) {
)
})
it('should fail when url is recursive', async () => {
const query = { url: `/_next/image?url=test.pngw=1&q=1`, w: ctx.w, q: 1 }
const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, {})
expect(res.status).toBe(400)
expect(await res.text()).toBe(`"url" parameter cannot be recursive`)
})
it('should fail when internal url is not an image', async () => {
const url = `/api/no-header`
const query = { url, w: ctx.w, q: 39 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment