Subject: bug#68508: closed (Re: bug#68508: [PATCH] ; (dom-print): Use HTML entities for reserved characters.)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 20 Jan 2024 09:43:02 +0000

Your bug report

#68508: [PATCH] ; (dom-print): Use HTML entities for reserved characters.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
68508: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68508
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#68508: [PATCH] ; (dom-print): Use HTML entities for reserved characters.
From: Eli Zaretskii <[email-masked]>
To: Eshel Yaron <[email-masked]>
Cc: [email-masked]
Date: Sat, 20 Jan 2024 11:42:07 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Eshel Yaron <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 16 Jan 2024 17:29:12 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Thanks, but could you please also add tests for this?
> 
> Sure, I've added a test to dom-tests.el in the updated patch below.

Thanks, installed on master, and closing the bug.

Subject: [PATCH] ; (dom-print): Use HTML entities for reserved characters.
From: Eshel Yaron <[email-masked]>
To: [email-masked]
Date: Tue, 16 Jan 2024 14:24:40 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

This makes `dom-print` encode HTML reserved characters that occur in
string elements of the DOM, to ensure the validity of the result.

For example, put the following in `foo.html`:

--8<---------------cut here---------------start------------->8---
<html><body>
Add ‘<samp class="samp">&lt;div class="default"&gt; &lt;/div&gt;</samp>’ tags around the fontified body.
<body><html>
--8<---------------cut here---------------end--------------->8---
(Fragment from https://www.gnu.org/software/emacs/manual/html_mono/htmlfontify.html)

Open that file in Emacs and say `M-: (require 'dom)` and then
`(dom-print (libxml-parse-html-region))` in the HTML buffer.  This
produces invalid HTML since `libxml-parse-html-region` correctly decodes
HTML entities, but `dom-print` doesn't encode (without this patch).

>From 259c0138623c352acc7bcd79a1fda42ec606a0cf Mon Sep 17 00:00:00 2001
From: Eshel Yaron <[email-masked]>
Date: Fri, 5 Jan 2024 16:40:44 +0100
Subject: [PATCH] ; (dom-print): Use HTML entities for reserved characters.

---
 lisp/dom.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/dom.el b/lisp/dom.el
index f7043ba8252..b329379fdc3 100644
--- a/lisp/dom.el
+++ b/lisp/dom.el
@@ -288,7 +288,7 @@ dom-print
 	(insert ">")
         (dolist (child children)
 	  (if (stringp child)
-	      (insert child)
+	      (insert (url-insert-entities-in-string child))
 	    (setq non-text t)
 	    (when pretty
               (insert "\n" (make-string (+ column 2) ?\s)))
-- 
2.42.0