mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
d9546d9504
* feat: use synchronous router design * feat: function to get router out of dom * chore: restructure workspace to use renderers as packages, not features
27 lines
590 B
Rust
27 lines
590 B
Rust
//! 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 {
|
|
let 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",
|
|
oninput: move |e| contents.set(e.value.clone()),
|
|
}
|
|
}
|
|
})
|
|
}
|