Commit 91db93a
fix(core): escape
* fix(core): escape `<` in the compiler-emitted variables script
`<script>` is a raw-text element: HTML serialization does not escape its
content, and the tokenizer ends it at the first `</script`. The statement
`buildVariablesByCompScript` emits embeds composition variables via
`JSON.stringify`, which escapes `"` and `\` but not `/` — so a variable
value, key, or composition id containing `</script>` terminated the element
early and the remainder was parsed as markup, corrupting the compiled
document.
Rewrite `<` to its JSON unicode escape. This is transparent to JSON.parse,
so the table the runtime reads is unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(core): centralize the JSON-in-script escape for every emitted literal
Escaping only the variables table left the composition id exploitable through
the wrapper it is emitted beside: wrapScopedCompositionScript serializes the
comp id, timeline comp id, authored root id, scope-selector override, error
label and two derived selector patterns with a bare JSON.stringify, and
wrapInlineScriptWithErrorBoundary does the same for the composition's own
source. All land in the same raw-text <script>, so any one of them could close
the element and have the remainder parsed as markup.
Route every literal through one jsonScriptLiteral helper instead of guarding
per value — the comp id alone reaches the emitted script through four separate
literals, which is how the first pass missed it.
Tests cover each wrapper literal via a serialize/reparse round trip, and every
payload now leads with a benign `<` ahead of its `</script`, so escaping only
the first match no longer passes.
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>< in the compiler-emitted variables script (#3071)1 parent 120ea37 commit 91db93a
2 files changed
Lines changed: 172 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
699 | 700 | | |
700 | 701 | | |
701 | 702 | | |
| 703 | + | |
702 | 704 | | |
703 | | - | |
| 705 | + | |
704 | 706 | | |
705 | 707 | | |
706 | 708 | | |
707 | 709 | | |
708 | | - | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
709 | 715 | | |
710 | 716 | | |
711 | 717 | | |
| |||
886 | 892 | | |
887 | 893 | | |
888 | 894 | | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
253 | 273 | | |
254 | 274 | | |
255 | 275 | | |
| |||
258 | 278 | | |
259 | 279 | | |
260 | 280 | | |
261 | | - | |
262 | | - | |
263 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
264 | 284 | | |
265 | | - | |
266 | | - | |
267 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
268 | 288 | | |
269 | 289 | | |
270 | | - | |
| 290 | + | |
271 | 291 | | |
272 | 292 | | |
273 | | - | |
| 293 | + | |
274 | 294 | | |
275 | 295 | | |
276 | 296 | | |
277 | 297 | | |
278 | 298 | | |
279 | 299 | | |
280 | 300 | | |
281 | | - | |
| 301 | + | |
282 | 302 | | |
283 | 303 | | |
284 | 304 | | |
| |||
585 | 605 | | |
586 | 606 | | |
587 | 607 | | |
588 | | - | |
| 608 | + | |
589 | 609 | | |
590 | 610 | | |
591 | 611 | | |
| |||
601 | 621 | | |
602 | 622 | | |
603 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
604 | 627 | | |
605 | 628 | | |
606 | 629 | | |
607 | 630 | | |
608 | 631 | | |
609 | | - | |
| 632 | + | |
| 633 | + | |
610 | 634 | | |
0 commit comments