Subject: [PATCH] Gnus HTML washing: Allow href surrounded by single-quotes

From: Nuno Silva <[email-masked]>
Date: Thu, 27 Mar 2025 11:47:51 +0000

Gnus, both in the version of Emacs I use locally, and in the development
repository, has the following in gnus-html-wash-tags
(lisp/gnus/gnus-html.el):

    (when (string-match "href=\"\\([^\"]+\\)" parameters)

This, in turn, makes it so that, at least when this function is involved
with displaying HTML parts, links that have single quotes surrounding
their target in the code are not linkified in the article display.

I noticed this when reading RSS/Atom feeds via feedbase.org, which uses
single quotes for the link associated with each post, as opposed to
Gmane's Gwene (which does not show this issue and uses double quotes for
said links), in an instance of Gnus which is using

    (setq mm-text-html-renderer 'gnus-w3m)

The attached patch has the modification that fixes this for me locally,
applied to git HEAD; please let me know if something should be done
differently.

For further context, check the subthread on the gmane.discuss group at
news.gmane.io (over netnews) starting at [1], especially [2] and [3].

The patch is almost identical to the change mentioned in [3], but does
not escape the second ' in the new regexp.

[1] Message-ID: <[email-masked]>,
    news://news.gmane.io/[email-masked]
    
[2] Message-ID: <[email-masked]>,
    news://news.gmane.io/[email-masked]
    
[3] Message-ID: <[email-masked]>,
    news://news.gmane.io/[email-masked]

-- 
Nuno Silva (aka njsg)
>From 64f1969fd1b728f40bb1f41150f17068dcddabe8 Mon Sep 17 00:00:00 2001
From: "Nuno J. Silva" <[email-masked]>
Date: Thu, 27 Mar 2025 11:25:01 +0000
Subject: [PATCH] Gnus html washing: allow href attribute surrounded by single
 quotes

---
 lisp/gnus/gnus-html.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
index 435ea11..cc63e96 100644
--- a/lisp/gnus/gnus-html.el
+++ b/lisp/gnus/gnus-html.el
@@ -258,17 +258,18 @@ Use ALT-TEXT for the image string."
 	(delete-region (match-beginning 0) (match-end 0)))
       (setq end (point))
       (cond
        ;; Fetch and insert a picture.
        ((equal tag "img_alt"))
        ;; Add a link.
        ((or (equal tag "a")
 	    (equal tag "A"))
-	(when (string-match "href=\"\\([^\"]+\\)" parameters)
+	(when (or (string-match "href=\"\\([^\"]+\\)" parameters)
+		  (string-match "href='\\([^']+\\)" parameters))
 	  (setq url (match-string 1 parameters))
           (gnus-message 8 "gnus-html-wash-tags: fetching link URL %s" url)
 	  (gnus-article-add-button start end
 				   'browse-url (mm-url-decode-entities-string url)
 				   url)
 	  (let ((overlay (make-overlay start end)))
 	    (overlay-put overlay 'evaporate t)
 	    (overlay-put overlay 'gnus-button-url url)