dioxus/examples/xss_safety.rs

28 lines
607 B
Rust
Raw Normal View History

//! XSS Safety
//!
//! This example proves that Dioxus is safe from XSS attacks.
use dioxus::prelude::*;
fn main() {
dioxus::desktop::launch(app);
}
fn app(cx: Scope) -> Element {
2022-01-26 02:41:40 +00:00
let (contents, set_contents) = use_state(&cx, || {
String::from("<script>alert(\"hello world\")</script>")
});
cx.render(rsx! {
div {
h1 {"Dioxus is XSS-Safe"}
h3 { "{contents}" }
input {
value: "{contents}",
r#type: "text",
2022-01-26 02:41:40 +00:00
oninput: move |e| set_contents(e.value.clone()),
}
}
})
}