bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#44348: 28.0.50; eww renders xml processing element as is


From: Stephen Berman
Subject: bug#44348: 28.0.50; eww renders xml processing element as is
Date: Sat, 31 Oct 2020 20:47:09 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Sat, 31 Oct 2020 21:17:35 +0530 Pankaj Jangid <pankaj@codeisgreat.org> wrote:

> I published a webpage using org. The output has this xml element at the
> top:
>
> <?xml version="1.0" encoding="utf-8"?>
>
> But this is rendered as it is in eww when I fetch it from the hosted
> website.
>
> When I view-source the element there is:
>
> &lt;?xml version="1.0" encoding="utf-8"?>
>
> Note that the opening angle bracket is converted to HTML entity type.

The simplest fix would seem to be this:

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fd9fe98439..051698d6d6 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -420,7 +420,7 @@ eww--preprocess-html
       (narrow-to-region start end)
       (goto-char start)
       (let ((case-fold-search t))
-        (while (re-search-forward "<[^0-9a-z!/]" nil t)
+        (while (re-search-forward "<[^0-9a-z!?/]" nil t)
           (goto-char (match-beginning 0))
           (delete-region (point) (1+ (point)))
           (insert "&lt;"))))))

But if that's too permissive, then a more specific fix is this:

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fd9fe98439..bc795df256 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -421,9 +421,11 @@ eww--preprocess-html
       (goto-char start)
       (let ((case-fold-search t))
         (while (re-search-forward "<[^0-9a-z!/]" nil t)
-          (goto-char (match-beginning 0))
-          (delete-region (point) (1+ (point)))
-          (insert "&lt;"))))))
+          (unless (and (looking-back "\\?" (line-beginning-position))
+                       (looking-at "xml"))
+            (goto-char (match-beginning 0))
+            (delete-region (point) (1+ (point)))
+            (insert "&lt;")))))))

 ;;;###autoload (defalias 'browse-web 'eww)

Steve Berman





reply via email to

[Prev in Thread] Current Thread [Next in Thread]