Escape HTML as we translate to rsx (#3038)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-10-08 07:02:02 -05:00
1 parent 9ffd4b816b
commit d64df87aba
4 files changed
+37 -1

No files matched your search

+6 -1
View File
@@ -9,6 +9,7 @@ use dioxus_rsx::{
HotLiteral, TemplateBody, TextNode,
};
pub use html_parser::{Dom, Node};
use htmlentity::entity::ICodedDataTrait;
use proc_macro2::{Ident, Span};
use syn::{punctuated::Punctuated, LitStr};
@@ -33,7 +34,11 @@ pub fn rsx_node_from_html(node: &Node) -> Option<BodyNode> {
use AttributeValue::*;
match node {
Node::Text(text) => Some(BodyNode::Text(TextNode::from_text(text))),
Node::Text(text) => Some(BodyNode::Text(TextNode::from_text(
&htmlentity::entity::decode(text.as_bytes())
.to_string()
.ok()?,
))),
Node::Element(el) => {
let el_name = if let Some(name) = map_html_element_to_rsx(&el.name) {