Skip to content

Commit 17bb6d4

Browse files
committed
Merge branch 'main' into mk/canary-demo
2 parents ee962b8 + 07e4094 commit 17bb6d4

File tree

6 files changed

+46
-17
lines changed

6 files changed

+46
-17
lines changed

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"packages/runtime": "4.24.1",
2+
"packages/runtime": "4.24.2",
33
"packages/next": "1.3.1"
44
}

package-lock.json

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/runtime/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [4.24.2](https://github.com/netlify/next-runtime/compare/plugin-nextjs-v4.24.1...plugin-nextjs-v4.24.2) (2022-10-05)
4+
5+
6+
### Bug Fixes
7+
8+
* validate next/image params ([#1661](https://github.com/netlify/next-runtime/issues/1661)) ([c0937cf](https://github.com/netlify/next-runtime/commit/c0937cf67e84d5e14c99670910ac33fc2dd0e166))
9+
310
## [4.24.1](https://github.com/netlify/next-runtime/compare/plugin-nextjs-v4.24.0...plugin-nextjs-v4.24.1) (2022-10-05)
411

512

packages/runtime/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netlify/plugin-nextjs",
3-
"version": "4.24.1",
3+
"version": "4.24.2",
44
"description": "Run Next.js seamlessly on Netlify",
55
"main": "lib/index.js",
66
"files": [
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@netlify/esbuild": "0.14.39",
1414
"@netlify/functions": "^1.3.0",
15-
"@netlify/ipx": "^1.2.5",
15+
"@netlify/ipx": "^1.3.0",
1616
"@vercel/node-bridge": "^2.1.0",
1717
"chalk": "^4.1.2",
1818
"destr": "^1.1.1",

packages/runtime/src/templates/edge/ipx.ts

+24-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ interface ImageConfig extends Record<string, unknown> {
99
formats?: string[]
1010
}
1111

12+
// Checks if a URL param is numeric
13+
const isNumeric = (value: string | null) => Number(value).toString() === value
14+
1215
/**
1316
* Implement content negotiation for images
1417
*/
@@ -28,10 +31,28 @@ const handler = async (req: Request, context: Context) => {
2831

2932
const source = searchParams.get('url')
3033
const width = searchParams.get('w')
31-
const quality = searchParams.get('q') ?? 75
34+
const quality = searchParams.get('q') ?? '75'
35+
36+
const errors: Array<string> = []
37+
38+
if (!source) {
39+
errors.push('Missing "url" parameter')
40+
} else if (!source.startsWith('http') && !source.startsWith('/')) {
41+
errors.push('The "url" parameter must be a valid URL or path')
42+
}
43+
44+
if (!width) {
45+
errors.push('Missing "w" parameter')
46+
} else if (!isNumeric(width)) {
47+
errors.push('Invalid "w" parameter')
48+
}
49+
50+
if (!isNumeric(quality)) {
51+
errors.push('Invalid "q" parameter')
52+
}
3253

33-
if (!source || !width) {
34-
return new Response('Invalid request', {
54+
if (!source || errors.length > 0) {
55+
return new Response(`Invalid request: \n${errors.join('\n')}`, {
3556
status: 400,
3657
})
3758
}

packages/runtime/src/templates/ipx.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export const handler: Handler = createIPXHandler({
1010
domains,
1111
remotePatterns,
1212
responseHeaders,
13+
localPrefix: '/_next/static/media/',
1314
}) as Handler
1415
/* eslint-enable n/no-missing-import, import/no-unresolved, @typescript-eslint/ban-ts-comment */

0 commit comments

Comments
 (0)