Skip to content

Commit 49f1af8

Browse files
fix(precompile): jsx child expression string literal not escaped (#304)
1 parent 2179368 commit 49f1af8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/transpiling/jsx_precompile.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ fn merge_serializable_children(
543543
}
544544
// Can be flattened
545545
Lit::Str(str_lit) => {
546-
buf.push_str(str_lit.value.as_ref());
546+
buf.push_str(&escape_html(str_lit.value.as_ref()));
547547
continue;
548548
}
549549
_ => {}
@@ -2051,6 +2051,16 @@ const $$_tpl_1 = [
20512051
];
20522052
const a = _jsxTemplate($$_tpl_1, _jsxEscape(foo), _jsxEscape(bar));"#,
20532053
);
2054+
2055+
test_transform(
2056+
JsxPrecompile::default(),
2057+
r#"const a = <div>{"\"a&>'"}</div>;"#,
2058+
r#"import { jsxTemplate as _jsxTemplate } from "react/jsx-runtime";
2059+
const $$_tpl_1 = [
2060+
"<div>&quot;a&amp;&gt;&#39;</div>"
2061+
];
2062+
const a = _jsxTemplate($$_tpl_1);"#,
2063+
);
20542064
}
20552065

20562066
#[test]

0 commit comments

Comments
 (0)