forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(next/image)!: error when
src
has leading or trailing space (ver…
…cel#65637) BREAKING CHANGE: Using the built-in image optimization API, the URL is parsed with `new URL()` constructor which automatically trims spaces. However, the developer may choose a 3rd party image optimization API via `loader` or `loaderFile` (or perhaps a deployment platform that has its own built in loader), so we shouldn't assume the API will parse the URL in the same way as [WHATWG](https://url.spec.whatwg.org/#:~:text=If%20input%20contains%20any%20leading%20or%20trailing%20C0%20control%20or%20space%2C%20invalid%2DURL%2Dunit%20validation%20error.). While we could trim on the client, its probably best to fail fast and let the developer make a conscience decision if a trailing space should be removed or remain (by explicitly using `%20`).
- Loading branch information
1 parent
975d953
commit 6ae5329
Showing
7 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/integration/next-image-new/app-dir/app/invalid-src-leading-space/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<h2>Invalid src with leading space</h2> | ||
<Image src=" /test.jpg" width={200} height={200} /> | ||
</div> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/integration/next-image-new/app-dir/app/invalid-src-trailing-space/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<h2>Invalid src with trailing space</h2> | ||
<Image src="/test.png " width={200} height={200} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/integration/next-image-new/default/pages/invalid-src-leading-space.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<h2>Invalid src with leading space</h2> | ||
<Image src=" /test.jpg" width={200} height={200} /> | ||
</div> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/integration/next-image-new/default/pages/invalid-src-trailing-space.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<h2>Invalid src with trailing space</h2> | ||
<Image src="/test.png " width={200} height={200} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters