escape text in ssr
This commit is contained in:
1 parent
bea16f151f
commit
c9f9b8b0fa
3 files changed
+13
-3
No files matched your search
@@ -14,6 +14,7 @@ keywords = ["dom", "ui", "gui", "react", "ssr"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dioxus-core = { path = "../core", version = "^0.3.0", features = ["serialize"] }
|
dioxus-core = { path = "../core", version = "^0.3.0", features = ["serialize"] }
|
||||||
|
askama_escape = "0.10.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
dioxus = { path = "../dioxus", version = "0.3.0" }
|
dioxus = { path = "../dioxus", version = "0.3.0" }
|
||||||
|
|||||||
@@ -82,7 +82,13 @@ impl StringCache {
|
|||||||
}
|
}
|
||||||
cur_path.pop();
|
cur_path.pop();
|
||||||
}
|
}
|
||||||
TemplateNode::Text { text } => write!(chain, "{text}")?,
|
TemplateNode::Text { text } => {
|
||||||
|
write!(
|
||||||
|
chain,
|
||||||
|
"{}",
|
||||||
|
askama_escape::escape(text, askama_escape::Html)
|
||||||
|
)?;
|
||||||
|
}
|
||||||
TemplateNode::Dynamic { id: idx } | TemplateNode::DynamicText { id: idx } => {
|
TemplateNode::Dynamic { id: idx } | TemplateNode::DynamicText { id: idx } => {
|
||||||
chain.segments.push(Segment::Node(*idx))
|
chain.segments.push(Segment::Node(*idx))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,8 +104,11 @@ impl Renderer {
|
|||||||
write!(buf, "<!--#-->")?;
|
write!(buf, "<!--#-->")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: escape the text
|
write!(
|
||||||
write!(buf, "{}", text.value)?;
|
buf,
|
||||||
|
"{}",
|
||||||
|
askama_escape::escape(text.value, askama_escape::Html)
|
||||||
|
)?;
|
||||||
|
|
||||||
if self.pre_render {
|
if self.pre_render {
|
||||||
write!(buf, "<!--#-->")?;
|
write!(buf, "<!--#-->")?;
|
||||||
|
|||||||
Reference in new issue
Block a user