From 59fa2fd099b5c4bc384575bdc86cbb06dd70a001 Mon Sep 17 00:00:00 2001 From: Sara Vieira Date: Thu, 22 Dec 2022 21:34:50 +0000 Subject: [PATCH 1/2] allow unsafe text in script --- typed-html/src/elements.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/typed-html/src/elements.rs b/typed-html/src/elements.rs index 5312da1..e69bfd1 100644 --- a/typed-html/src/elements.rs +++ b/typed-html/src/elements.rs @@ -311,7 +311,7 @@ declare_elements! { src: Uri, text: String, type: String, // TODO could be an enum - } in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent] with TextNode; + } in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent] with PhrasingContent; section in [FlowContent, SectioningContent] with FlowContent; select { autocomplete: String, @@ -488,3 +488,18 @@ fn test_aria() { frag.to_string() ); } + +#[test] +fn test_js() { + use crate as axohtml; + use crate::{dom::DOMTree, html, text, unsafe_text}; + + let frag: DOMTree = html!(); + let frag1: DOMTree = html!(); + + assert_eq!("", frag.to_string()); + assert_eq!( + "", + frag1.to_string() + ); +} From 0384d4e4fbc3d7ac8e9bd4dfb887b753f753bef9 Mon Sep 17 00:00:00 2001 From: Sara Vieira Date: Fri, 23 Dec 2022 15:59:28 +0000 Subject: [PATCH 2/2] only allow unsafe --- typed-html/src/elements.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/typed-html/src/elements.rs b/typed-html/src/elements.rs index e69bfd1..d80917e 100644 --- a/typed-html/src/elements.rs +++ b/typed-html/src/elements.rs @@ -2,7 +2,7 @@ #![allow(non_camel_case_types)] -use crate::dom::{Node, TextNode}; +use crate::dom::{Node, TextNode, UnsafeTextNode}; use crate::types::*; use crate::OutputType; use axohtml_macros::declare_elements; @@ -311,7 +311,7 @@ declare_elements! { src: Uri, text: String, type: String, // TODO could be an enum - } in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent] with PhrasingContent; + } in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent] with UnsafeTextNode; section in [FlowContent, SectioningContent] with FlowContent; select { autocomplete: String, @@ -492,14 +492,9 @@ fn test_aria() { #[test] fn test_js() { use crate as axohtml; - use crate::{dom::DOMTree, html, text, unsafe_text}; + use crate::{dom::DOMTree, html, unsafe_text}; let frag: DOMTree = html!(); - let frag1: DOMTree = html!(); assert_eq!("", frag.to_string()); - assert_eq!( - "", - frag1.to_string() - ); }