all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: omar.antolin@gmail.com
Cc: 30664@debbugs.gnu.org
Subject: bug#30664: 25.2; eww-download corrupts PDF files (and probably other binary files too)
Date: Thu, 01 Mar 2018 21:17:08 +0200	[thread overview]
Message-ID: <834llzy5aj.fsf@gnu.org> (raw)
In-Reply-To: <86muzrdbyx.fsf@gmail.com> (omar.antolin@gmail.com)

> From: omar.antolin@gmail.com
> Date: Thu, 01 Mar 2018 09:58:30 -0600
> 
> 
> I tried using eww-download (bound to `d` in eww buffers) to download a
> PDF file. This produced, as expected a file in my downloads directory,
> but I could not open it in my PDF reader. I immediately suspected that
> Emacs had done some unwanted coding system translation on the PDF file.
> 
> The variable `last-coding-system-used` was set to `raw-text-dos` (I'm
> using Emacs 25.2 on Windows 10), and the `dos` part sounded suspicious
> to me. Adding the item `("\\.pdf\\'" no-conversion . no-conversion)` to
> the variable `file-coding-system-alist` and redownloading the file fixed
> the problem and produced a valid PDF file.

Does the patch below fix the problem?

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index caac96a..66b1767 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1532,7 +1532,8 @@ eww-download-callback
                   eww-download-directory)))
       (goto-char (point-min))
       (re-search-forward "\r?\n\r?\n")
-      (write-region (point) (point-max) file)
+      (let ((coding-system-for-write 'no-conversion))
+        (write-region (point) (point-max) file))
       (message "Saved %s" file))))
 
 (defun eww-decode-url-file-name (string)





  parent reply	other threads:[~2018-03-01 19:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01 15:58 bug#30664: 25.2; eww-download corrupts PDF files (and probably other binary files too) omar.antolin
2018-03-01 17:10 ` Andreas Schwab
2018-03-01 19:18   ` Eli Zaretskii
2018-03-01 19:17 ` Eli Zaretskii [this message]
     [not found]   ` <CAL03oyLjOiFtdiY+_OCHHSSzn+7iEepZAHq08fOvMiN2HhLpqQ@mail.gmail.com>
2018-03-02  8:46     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=834llzy5aj.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=30664@debbugs.gnu.org \
    --cc=omar.antolin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.