-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not re-escape cookies collected from fetch calls during SSR (#…
…11904) * fix: do not re-escape cookies collected from fetch calls during SSR * add test * add changeset
- Loading branch information
Showing
6 changed files
with
33 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@sveltejs/kit": patch | ||
--- | ||
|
||
fix: avoid incorrectly un- and re-escaping cookies collected during a server-side `fetch` |
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
10 changes: 10 additions & 0 deletions
10
packages/kit/test/apps/basics/src/routes/cookies/collect-without-re-escaping/+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,10 @@ | ||
import { browser } from '$app/environment'; | ||
|
||
/** @type {import('@sveltejs/kit').Load}*/ | ||
export async function load({ fetch }) { | ||
if (!browser) { | ||
// We don't want the client-side collected cookie to clobber the | ||
// server-side collected cookie that we're actually testing. | ||
await fetch('/cookies/collect-without-re-escaping/set-cookie'); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/kit/test/apps/basics/src/routes/cookies/collect-without-re-escaping/+page.svelte
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,5 @@ | ||
<script> | ||
import { browser } from '$app/environment'; | ||
</script> | ||
|
||
<p>{browser && document.cookie}</p> |
4 changes: 4 additions & 0 deletions
4
...kit/test/apps/basics/src/routes/cookies/collect-without-re-escaping/set-cookie/+server.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,4 @@ | ||
/** @type {import('@sveltejs/kit').RequestHandler} */ | ||
export async function GET() { | ||
return new Response(null, { headers: { 'set-cookie': 'cookie-special-characters="foo"' } }); | ||
} |
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