xss_safety.rs 646 B

12345678910111213141516171819202122232425262728293031
  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 {
  11. "{contents}"
  12. }
  13. h3 {
  14. [contents.as_str()]
  15. }
  16. input {
  17. value: "{contents}",
  18. oninput: move |e| {
  19. contents.set(e.value.clone());
  20. eprintln!("asd");
  21. },
  22. "type": "text",
  23. }
  24. }
  25. })
  26. }