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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 16 Jan 2024 15:47:30 +0200

> Date: Tue, 16 Jan 2024 14:24:40 +0100
> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> 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).

Thanks, but could you please also add tests for this?