xss_safety.rs 591 B

12345678910111213141516171819202122232425262728
  1. use dioxus::prelude::*;
  2. fn main() {
  3. dioxus::desktop::launch(app);
  4. }
  5. fn app(cx: Scope) -> Element {
  6. let contents = use_state(&cx, || String::from("<script>alert(123)</script>"));
  7. cx.render(rsx! {
  8. div {
  9. "hello world!"
  10. h1 { "{contents}" }
  11. h3 { [contents.as_str()] }
  12. input {
  13. value: "{contents}",
  14. oninput: move |e| {
  15. contents.set(e.value.clone());
  16. eprintln!("asd");
  17. },
  18. "type": "text",
  19. }
  20. }
  21. })
  22. }