@@ -154,10 +154,7 @@ export function renderToStream(code, options = {}) {
154154 const first = html . indexOf ( placeholder ) ;
155155 if ( first === - 1 ) return ;
156156 const last = html . indexOf ( `<!--!$/${ id } -->` , first + placeholder . length ) ;
157- html = html . replace (
158- html . slice ( first , last + placeholder . length + 1 ) ,
159- resolveSSRNode ( payloadFn ( ) )
160- ) ;
157+ html = html . slice ( 0 , first ) + resolveSSRNode ( escape ( payloadFn ( ) ) ) + html . slice ( last + placeholder . length + 1 ) ;
161158 } ,
162159 serialize ( id , p , wait ) {
163160 const serverOnly = sharedConfig . context . noHydrate ;
@@ -513,7 +510,7 @@ export function getHydrationKey() {
513510}
514511
515512export function useAssets ( fn ) {
516- sharedConfig . context . assets . push ( ( ) => resolveSSRNode ( fn ( ) ) ) ;
513+ sharedConfig . context . assets . push ( ( ) => resolveSSRNode ( escape ( fn ( ) ) ) ) ;
517514}
518515
519516export function getAssets ( ) {
@@ -567,7 +564,9 @@ function injectAssets(assets, html) {
567564 if ( ! assets || ! assets . length ) return html ;
568565 let out = "" ;
569566 for ( let i = 0 , len = assets . length ; i < len ; i ++ ) out += assets [ i ] ( ) ;
570- return html . replace ( `</head>` , out + `</head>` ) ;
567+ const index = html . indexOf ( "</head>" ) ;
568+ if ( index === - 1 ) return html ;
569+ return html . slice ( 0 , index ) + out + html . slice ( index ) ;
571570}
572571
573572function injectScripts ( html , scripts , nonce ) {
0 commit comments