* [yew-devel] [PATCH proxmox-yew-comp] fix: add a `div` wrapper element around the notes content
@ 2025-12-02 15:01 Shan Shaji
2025-12-03 12:51 ` Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Shan Shaji @ 2025-12-02 15:01 UTC (permalink / raw)
To: yew-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [yew-devel] [PATCH proxmox-yew-comp] fix: add a `div` wrapper element around the notes content
2025-12-02 15:01 [yew-devel] [PATCH proxmox-yew-comp] fix: add a `div` wrapper element around the notes content Shan Shaji
@ 2025-12-03 12:51 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2025-12-03 12:51 UTC (permalink / raw)
To: yew-devel, Shan Shaji
On Tue, 02 Dec 2025 16:01:09 +0100, Shan Shaji wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] fix: add a `div` wrapper element around the notes content
commit: 580f69671e70473a8aeb5075df29b58ca1803a5a
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-03 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-02 15:01 [yew-devel] [PATCH proxmox-yew-comp] fix: add a `div` wrapper element around the notes content Shan Shaji
2025-12-03 12:51 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox