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

Previous Next

Package: emacs;

Reported by: Łukasz Stelmach <steelman <at> post.pl>

Date: Mon, 21 Dec 2020 20:37:02 UTC

Severity: normal

Tags: fixed

Found in version 26.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45355 in the body.
You can then email your comments to 45355 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#45355; Package emacs. (Mon, 21 Dec 2020 20:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Łukasz Stelmach <steelman <at> post.pl>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 21 Dec 2020 20:37:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Łukasz Stelmach <steelman <at> post.pl>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; shr-tag-base doesn't handle <base href=""> properly
Date: Mon, 21 Dec 2020 21:35:57 +0100
[Message part 1 (text/plain, inline)]
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
[0001-Handle-gracefully-href-in-base-tags.patch (text/x-diff, inline)]
From f92e8b8ab5b6f0970611c91cf80e418712ed2b58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= <stlman <at> 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


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45355; Package emacs. (Tue, 22 Dec 2020 06:49:02 GMT) Full text and rfc822 format available.

Message #8 received at 45355 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Łukasz Stelmach <steelman <at> post.pl>
Cc: 45355 <at> debbugs.gnu.org
Subject: Re: bug#45355: 26.1; shr-tag-base doesn't handle <base href="">
 properly
Date: Tue, 22 Dec 2020 07:47:54 +0100
Łukasz Stelmach <steelman <at> post.pl> writes:

> 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.

Looks good to me; I've now applied it to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 22 Dec 2020 06:49:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 45355 <at> debbugs.gnu.org and Łukasz Stelmach <steelman <at> post.pl> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 22 Dec 2020 06:49:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 19 Jan 2021 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 148 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.