File tree Expand file tree Collapse file tree 1 file changed +4
-16
lines changed
packages/angular/build/src/utils/server-rendering Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,8 @@ const MAIN_SERVER_OUTPUT_FILENAME = 'main.server.mjs';
24
24
* A mapping of unsafe characters to their escaped Unicode equivalents.
25
25
*/
26
26
const UNSAFE_CHAR_MAP : Record < string , string > = {
27
- '<' : '\\u003C' ,
28
- '>' : '\\u003E' ,
29
- '/' : '\\u002F' ,
30
- '\\' : '\\\\' ,
31
- '\b' : '\\b' ,
32
- '\f' : '\\f' ,
33
- '\n' : '\\n' ,
34
- '\r' : '\\r' ,
35
- '\t' : '\\t' ,
36
- '\0' : '\\0' ,
37
- '\u2028' : '\\u2028' ,
38
- '\u2029' : '\\u2029' ,
27
+ '`' : '\\`' ,
28
+ '$' : '\\$' ,
39
29
} ;
40
30
41
31
/**
@@ -46,7 +36,7 @@ const UNSAFE_CHAR_MAP: Record<string, string> = {
46
36
* @returns The escaped string where unsafe characters are replaced.
47
37
*/
48
38
function escapeUnsafeChars ( str : string ) : string {
49
- return str . replace ( / [ < > \b \f \n \r \t \0 \u2028 \u2029 ] / g, ( c ) => UNSAFE_CHAR_MAP [ c ] ) ;
39
+ return str . replace ( / [ $ ` ] / g, ( c ) => UNSAFE_CHAR_MAP [ c ] ) ;
50
40
}
51
41
52
42
/**
@@ -149,9 +139,7 @@ export function generateAngularServerAppManifest(
149
139
file . path === INDEX_HTML_CSR ||
150
140
( inlineCriticalCss && file . path . endsWith ( '.css' ) )
151
141
) {
152
- serverAssetsContent . push (
153
- `['${ file . path } ', async () => ${ escapeUnsafeChars ( JSON . stringify ( file . text ) ) } ]` ,
154
- ) ;
142
+ serverAssetsContent . push ( `['${ file . path } ', async () => \`${ escapeUnsafeChars ( file . text ) } \`]` ) ;
155
143
}
156
144
}
157
145
You can’t perform that action at this time.
0 commit comments