Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
28fc8944
Unverified
Commit
28fc8944
authored
Jul 04, 2024
by
Steven
Committed by
GitHub
Jul 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(next/image): handle invalid url (#67465)
parent
38b34231
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
image-optimizer.ts
packages/next/src/server/image-optimizer.ts
+6
-0
util.ts
test/integration/image-optimizer/test/util.ts
+7
-0
No files found.
packages/next/src/server/image-optimizer.ts
View file @
28fc8944
...
@@ -213,6 +213,12 @@ export class ImageOptimizerCache {
...
@@ -213,6 +213,12 @@ export class ImageOptimizerCache {
}
}
}
}
if
(
url
.
startsWith
(
'/_next/image'
))
{
return
{
errorMessage
:
'"url" parameter cannot be recursive'
,
}
}
let
isAbsolute
:
boolean
let
isAbsolute
:
boolean
if
(
url
.
startsWith
(
'/'
))
{
if
(
url
.
startsWith
(
'/'
))
{
...
...
test/integration/image-optimizer/test/util.ts
View file @
28fc8944
...
@@ -1021,6 +1021,13 @@ export function runTests(ctx: RunTestsCtx) {
...
@@ -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
()
=>
{
it
(
'should fail when internal url is not an image'
,
async
()
=>
{
const
url
=
`/api/no-header`
const
url
=
`/api/no-header`
const
query
=
{
url
,
w
:
ctx
.
w
,
q
:
39
}
const
query
=
{
url
,
w
:
ctx
.
w
,
q
:
39
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment