all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Shan Shaji <s.shaji@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH proxmox-yew-comp] fix: add a `div` wrapper element around the notes content
Date: Tue,  2 Dec 2025 16:01:09 +0100	[thread overview]
Message-ID: <20251202150109.455810-1-s.shaji@proxmox.com> (raw)

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@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



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


             reply	other threads:[~2025-12-02 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02 15:01 Shan Shaji [this message]
2025-12-03 12:51 ` Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251202150109.455810-1-s.shaji@proxmox.com \
    --to=s.shaji@proxmox.com \
    --cc=yew-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal