GNU bug report logs - #24893
26.0.50; shr doesn't parse srcset <img> correctly

Previous Next

Package: emacs;

Reported by: Lars Ingebrigtsen <larsi <at> gnus.org>

Date: Mon, 7 Nov 2016 11:16:02 UTC

Severity: normal

Tags: fixed

Found in version 26.0.50

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

Bug is archived. No further changes may be made.

Full log


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

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 24893 <at> debbugs.gnu.org
Subject: Re: bug#24893: 26.0.50; shr doesn't parse srcset <img> correctly
Date: Tue, 08 Nov 2016 14:55:49 +0900
[Message part 1 (text/plain, inline)]
On Mon, 07 Nov 2016 12:11:51 +0100, Lars Ingebrigtsen wrote:
> (shr--preferred-image
[...]
> => "
> "
> I'm guessing it's the newlines or something that's the problem.  Or the
> protocol-less URLs?  I haven't examined.

Though this is no more than a workaround:

[Message part 2 (text/x-patch, inline)]
--- shr.el~	2016-11-04 10:32:58.932040100 +0000
+++ shr.el	2016-11-08 05:54:35.912122700 +0000
@@ -1529,7 +1529,7 @@
       (setq srcset
             (sort (mapcar
                    (lambda (elem)
-                     (let ((spec (split-string elem " ")))
+                     (let ((spec (split-string elem "[\t\n ]+")))
                        (cond
                         ((= (length spec) 1)
                          ;; Make sure it's well formed.
@@ -1543,7 +1543,9 @@
                         (t
                          (list (car spec)
                                (string-to-number (cadr spec)))))))
-                   (split-string srcset ", "))
+                   (split-string (replace-regexp-in-string
+				  "\\`[\t\n ]+\\|[\t\n ]+\\'" "" srcset)
+				 "[\t\n ]*,[\t\n ]*"))
                   (lambda (e1 e2)
                     (> (cadr e1) (cadr e2)))))
       ;; Choose the smallest picture that's bigger than the current

This bug report was last modified 8 years and 122 days ago.

Previous Next


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