fixes shadow hydration escaping - #3793
Conversation
🦋 Changeset detectedLatest commit: 0da6c8f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
✔️ Deploy Preview for kit-demo canceled. 🔨 Explore the source changes: 0da6c8f 🔍 Inspect the deploy log: https://app.netlify.com/sites/kit-demo/deploys/6203ee9b50a2ee0008998ab6 |
|
I also tried using devalue package but it's the same, html becomes malformed. This way is vulnerable to XSS probably so not the best way, but just a suggestion. |
|
Actually I found out that Next.js is using the same(similar) strategy with regex like this PR: I'll improve this a little but this isn't that bad. |
|
we have a utility for that kit/packages/kit/src/utils/escape.js Line 19 in 59badb5 |
|
and it would be great to have a test in https://github.com/sveltejs/kit/tree/master/packages/kit/test/apps/basics/src/routes/xss so that we can catch regressions. |
|
Thanks, I actually adopted the code from Next.js in the latest commit, but I'll implement that code now you suggested because DRY. |
|
@PH4NTOMiki i pushed a fix for the invalid double-qoute escape and added a test. hope you don't mind. this is kind of urgent 😬 |
Yeah, of course, thank you |
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
|
Looks like you'll need to run |
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
There was a problem hiding this comment.
I had a couple suggestions for the jsdocs, but otherwise lgtm
I would like to get another set of eyes from @Conduitry though since he was more involved in #2534. Or Rich since he added the original escape mechanism in #882
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
|
these docs describe where the escaped result can be safely used, not how the return value looks like. see it's actually a string prop on a larger json thats added to a script block elsewhere later. Not fond of this complexity but it is what it is. I'd like to merge this first and we can improve the docs in a followup PR. |
|
Something in this PR seems to have broken https://kit.svelte.dev/docs |
|
@dominikg what do you think? |
|
Or should I try to PR that again? |
|
@benmccann also, is there any change that that Vite update could be causing anything? maybe together with this, or alone? |
|
It works if I revert this line: |
|
Isn't that the current/latest line? |
|
Yes, and it's broken |
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
fixes #3773
there are many better ways to solve this, if anyone has a suggestion.
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpx changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0