-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Hydration Inconsistency: Escaped linebreaks in attributes #7327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This seems to be a bug in Svelte itself; it's rendering attributes inconsistently between the client and the server. It looks like when server-side rendering, Svelte JSON-encodes attributes. If you have a string SvelteKit does include the original data as a payload in the server-side rendered page, so the components get the original data back during hydration—that's why it's only messing with the values before hydration (or with javascript disabled). |
Fixes #7327 and a related security issue
Fixes sveltejs#7327 and a related security issue
This should be fixed in 3.46.5. |
I feel like this or a very similar bug is still present in 3.50.1 (see #7848). |
Describe the bug
When setting an attribute value to a string (eg:
<input type=hidden name="foo" value={bar} />
), if the string include a line break (eg:\n
or\r\n
), the HTML sent to the browser results in the the value being escaped. After hydration occurs, the value is reset to the expected value.Reproduction
npm install
npm run dev
localhost:3000
and ensure javascript is enabled on the page.localhost:3000
and ensure javascript is disabled on the page (to prevent hydration).Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: