[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30664: 25.2; eww-download corrupts PDF files (and probably other bin

From: Eli Zaretskii
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

> From: address@hidden
> 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
       (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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]