[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24893: 26.0.50; shr doesn't parse srcset <img> correctly
From: |
Katsumi Yamaoka |
Subject: |
bug#24893: 26.0.50; shr doesn't parse srcset <img> correctly |
Date: |
Tue, 08 Nov 2016 14:55:49 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (i686-pc-cygwin) |
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:
--- 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