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

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

bug#45355: 26.1; shr-tag-base doesn't handle <base href=""> properly


From: Łukasz Stelmach
Subject: bug#45355: 26.1; shr-tag-base doesn't handle <base href=""> properly
Date: Mon, 21 Dec 2020 21:35:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

For what it's worth, W3C HTML Validator claims that a document with an
empty string in the href attribute of a base tag

    <base href="">

is valid. I found such document recently in my INBOX and Gnus was unable
to display it correctly because the second string-match in
shr-parse-base breaks when local is nil. My solution is not to call
shr-parse-base not only when href is not present but also when href is
an empty string.

The patch has been crated on the current master branch.
-- 
Kind regards,
Łukasz Stelmach
>From f92e8b8ab5b6f0970611c91cf80e418712ed2b58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= <stlman@poczta.fm>
Date: Mon, 21 Dec 2020 21:07:28 +0100
Subject: [PATCH] Handle gracefully href="" in base tags

* net/shr.el (shr-tag-base): shr-parse-base can't handle empty strings
gracefully. Don't call it unless href is a non-empty string.
---
 lisp/net/shr.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 2e5dd5ffa5..150ad88d4c 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1516,8 +1516,9 @@ ones, in case fg and bg are nil."
       plist)))
 
 (defun shr-tag-base (dom)
-  (when-let* ((base (dom-attr dom 'href)))
-    (setq shr-base (shr-parse-base base)))
+  (let* ((base (dom-attr dom 'href)))
+    (when (> (length base) 0)
+      (setq shr-base (shr-parse-base base))))
   (shr-generic dom))
 
 (defun shr-tag-a (dom)
-- 
2.20.1


reply via email to

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