File tree 1 file changed +3
-19
lines changed
packages/kit/src/runtime/server/page
1 file changed +3
-19
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import devalue from 'devalue';
2
2
import { readable , writable } from 'svelte/store' ;
3
3
import { coalesce_to_error } from '../../../utils/error.js' ;
4
4
import { hash } from '../../hash.js' ;
5
- import { escape_html_attr } from '../../../utils/escape.js' ;
5
+ import { escape_html_attr , escape_json_string_in_html } from '../../../utils/escape.js' ;
6
6
import { s } from '../../../utils/misc.js' ;
7
7
import { create_prerendering_url_proxy } from './utils.js' ;
8
8
import { Csp , csp_ready } from './csp.js' ;
@@ -260,24 +260,8 @@ export async function render_response({
260
260
. join ( '\n\t' ) ;
261
261
262
262
if ( shadow_props ) {
263
- // adapted from https://github.com/vercel/next.js/blob/694407450638b037673c6d714bfe4126aeded740/packages/next/server/htmlescape.ts
264
- // based on https://github.com/zertosh/htmlescape
265
- // License: https://github.com/zertosh/htmlescape/blob/0527ca7156a524d256101bb310a9f970f63078ad/LICENSE
266
- /**
267
- * @type { Record<string, string> }
268
- */
269
- const escape_lookup = {
270
- '&' : '\\u0026' ,
271
- '>' : '\\u003e' ,
272
- '<' : '\\u003c' ,
273
- '\u2028' : '\\u2028' ,
274
- '\u2029' : '\\u2029'
275
- } ;
276
- const escaped_shadow_props = s ( shadow_props ) . replace (
277
- / [ & > < \u2028 \u2029 ] / g,
278
- ( match ) => escape_lookup [ match ]
279
- ) ;
280
- body += `<script type="application/json" data-type="svelte-props">${ escaped_shadow_props } </script>` ;
263
+ // prettier-ignore
264
+ body += `<script type="application/json" data-type="svelte-props">${ escape_json_string_in_html ( s ( shadow_props ) ) } </script>` ;
281
265
}
282
266
}
283
267
You can’t perform that action at this time.
0 commit comments