GNU bug report logs -
#8827
Problem in url-cache
Previous Next
Reported by: nicholas.dokos <at> hp.com
Date: Wed, 8 Jun 2011 23:37:02 UTC
Severity: normal
Done: Julien Danjou <julien <at> danjou.info>
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 8827 in the body.
You can then email your comments to 8827 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#8827
; Package
emacs
.
(Wed, 08 Jun 2011 23:37:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
nicholas.dokos <at> hp.com
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 08 Jun 2011 23:37:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I was chasing down some problems I was having with Julien Danjou's
google-weather. The blow-by-blow description can be found in the
following threads on the emacs and orgmode mailing lists:
http://thread.gmane.org/gmane.emacs.help/81302
http://thread.gmane.org/gmane.emacs.orgmode/42565
This bug report (and possible patch) concern one aspect of this:
google-weather uses the url package to retrieve icons in GIF format (but
the problem may arise from any kind of binary data) from the server and
caches them locally for 12 hours by default. It does that by calling
url-store-in-cache:
(defun url-store-in-cache (&optional buff)
"Store buffer BUFF in the cache."
(with-current-buffer (get-buffer (or buff (current-buffer)))
(let ((fname (url-cache-create-filename (url-view-url t))))
(if (url-cache-prepare fname)
(let ((coding-system-for-write 'binary))
(write-region (point-min) (point-max) fname nil 5))))))
While the cache is valid, it then fetches the cached data by calling
url-cache-extract:
(defun url-cache-extract (fnam)
"Extract FNAM from the local disk cache."
(erase-buffer)
(insert-file-contents-literally fnam))
But it seems that in a multibyte context, what url-store-in-cache
stores and what url-cache-extract retrieves are not identical:
the former stores a sequence of bytes as they come from the network
and the latter may combine individual bytes into multibyte entities.
My workaround for this problem is
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 1615920..80d7702 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -192,6 +192,7 @@ Very fast if you have an `md5' primitive function, suitably fast otherwise."
(defun url-cache-extract (fnam)
"Extract FNAM from the local disk cache."
(erase-buffer)
+ (set-buffer-multibyte nil)
(insert-file-contents-literally fnam))
(defun url-cache-expired (url &optional expire-time)
--8<---------------cut here---------------end--------------->8---
It seems to work satisfactorily for google-weather. I don't know whether
it causes problems in other ways.
Thanks,
Nick
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#8827
; Package
emacs
.
(Thu, 09 Jun 2011 07:38:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 8827 <at> debbugs.gnu.org (full text, mbox):
> From: Nick Dokos <nicholas.dokos <at> hp.com>
> Date: Wed, 08 Jun 2011 19:35:45 -0400
> Cc: Julien Danjou <julien <at> danjou.info>, nicholas.dokos <at> hp.com
>
> (defun url-cache-extract (fnam)
> "Extract FNAM from the local disk cache."
> (erase-buffer)
> (insert-file-contents-literally fnam))
>
> But it seems that in a multibyte context, what url-store-in-cache
> stores and what url-cache-extract retrieves are not identical:
> the former stores a sequence of bytes as they come from the network
> and the latter may combine individual bytes into multibyte entities.
>
> My workaround for this problem is
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
> index 1615920..80d7702 100644
> --- a/lisp/url/url-cache.el
> +++ b/lisp/url/url-cache.el
> @@ -192,6 +192,7 @@ Very fast if you have an `md5' primitive function, suitably fast otherwise."
> (defun url-cache-extract (fnam)
> "Extract FNAM from the local disk cache."
> (erase-buffer)
> + (set-buffer-multibyte nil)
> (insert-file-contents-literally fnam))
That's not a workaround, that's exactly the fix for this bug.
Inserting binary data into a multibyte buffer does not leave the
binary data unaltered. The buffer must be unibyte.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#8827
; Package
emacs
.
(Wed, 06 Jul 2011 07:50:03 GMT)
Full text and
rfc822 format available.
Message #11 received at 8827 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
close 8827
thanks
I've pushed your fix into the trunk.
--
Julien Danjou
❱ http://julien.danjou.info
[Message part 2 (application/pgp-signature, inline)]
bug closed, send any further explanations to
8827 <at> debbugs.gnu.org and nicholas.dokos <at> hp.com
Request was from
Julien Danjou <julien <at> danjou.info>
to
control <at> debbugs.gnu.org
.
(Wed, 06 Jul 2011 07:50:04 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
.
(Wed, 03 Aug 2011 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 328 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.