[emacs-w3m:13270] Re: oneline patch to ~/.emacs.d/elpa/w3m-20190222.738/w3m-favicon.el

Boruch Baum <[email protected]>
Newsgroups gmane.emacs.w3m
Message-ID <[email protected]>
On 2019-02-25 15:28, [email protected] wrote:
> Then on some sites I am getting an "out of range" error.
>
> so I have added this line to the function
> --8<---------------cut here---------------start------------->8---
> (defun w3m-favicon-convert (data type)
>   "Convert the favicon DATA in TYPE to the favicon image and return it."
> +  (when (> (length data) 0)
>   (when (or (not (eq type 'ico))
> --8<---------------cut here---------------end--------------->8---
>
> And obviously. You would need to add the closing parentheses at the end.
>
> Perhaps someone could add that simple patch or elaborate a better
> version of the patch.

Thanks Andres,

I've prepared a patch and github pull request that changes the `when'
function to explicitly make the two required bounds checks.

  (when (or (not (eq type 'ico))
	    ;; Is it really in the ico format?
	    (and (>= (length data) 4)
                 (string-equal "\x00\x00\x01\x00" (substring data 0 4)))
	    ;; Some icons named favicon.ico are animated GIFs.
	    (and (>= (length data) 5)
                 (member (substring data 0 5) '("GIF87" "GIF89"))
		 (setq type 'gif)))


-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.