2022-01-02 18:35:38 -05:00
|
|
|
//! XSS Safety
|
|
|
|
//!
|
|
|
|
//! This example proves that Dioxus is safe from XSS attacks.
|
|
|
|
|
2021-12-30 03:14:47 -05:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
fn main() {
|
2024-10-10 18:00:58 -05:00
|
|
|
dioxus::launch(app);
|
2021-12-30 03:14:47 -05:00
|
|
|
}
|
|
|
|
|
2024-01-13 20:51:37 -08:00
|
|
|
fn app() -> Element {
|
2024-01-15 23:24:59 -08:00
|
|
|
let mut contents = use_signal(|| String::from("<script>alert(\"hello world\")</script>"));
|
2021-12-30 03:14:47 -05:00
|
|
|
|
2024-01-16 13:18:46 -06:00
|
|
|
rsx! {
|
2021-12-30 03:14:47 -05:00
|
|
|
div {
|
2022-01-03 00:42:17 -05:00
|
|
|
h1 {"Dioxus is XSS-Safe"}
|
2022-01-02 18:35:38 -05:00
|
|
|
h3 { "{contents}" }
|
2021-12-30 03:14:47 -05:00
|
|
|
input {
|
|
|
|
value: "{contents}",
|
2022-01-02 18:35:38 -05:00
|
|
|
r#type: "text",
|
2023-09-01 15:38:55 -05:00
|
|
|
oninput: move |e| contents.set(e.value()),
|
2021-12-30 03:14:47 -05:00
|
|
|
}
|
|
|
|
}
|
2024-01-13 21:12:21 -08:00
|
|
|
}
|
2021-12-30 03:14:47 -05:00
|
|
|
}
|