[yew-devel] [PATCH proxmox-yew-comp] fix: add a `div` wrapper element around the notes content
Shan Shaji
s.shaji at proxmox.com
Tue Dec 2 16:01:09 CET 2025
When the <script> element is placed on the first line of the note,
the `DomParser` parses it and moves it into the <head> element. As a
result, the <body> does not contain the <script> element, and the
NoteView fails to display it. However, when the <script> element is
placed between two lines, it is correctly placed inside the <body>.
To fix this issue, a wrapper <div> element has been added around the
note string.
Signed-off-by: Shan Shaji <s.shaji at proxmox.com>
---
src/sanitize_html.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/sanitize_html.rs b/src/sanitize_html.rs
index ff058c7..88515ed 100644
--- a/src/sanitize_html.rs
+++ b/src/sanitize_html.rs
@@ -99,10 +99,11 @@ fn sanitize_html_element(node: &web_sys::Node, base_url: &str) -> Result<(), Err
pub fn sanitize_html(text: &str) -> Result<String, Error> {
let location = gloo_utils::window().location();
let origin = location.origin().unwrap_or_default();
+ let wrapped = format!("<div>{}</div>", text);
let dom_parser = web_sys::DomParser::new().map_err(convert_js_error)?;
let doc = dom_parser
- .parse_from_string(text, web_sys::SupportedType::TextHtml)
+ .parse_from_string(&wrapped, web_sys::SupportedType::TextHtml)
.map_err(convert_js_error)?;
if let Some(body) = doc.body() {
--
2.47.3
More information about the yew-devel
mailing list