GNU bug report logs -
#30664
25.2; eww-download corrupts PDF files (and probably other binary files too)
Previous Next
Reported by: omar.antolin <at> gmail.com
Date: Thu, 1 Mar 2018 16:39:02 UTC
Severity: normal
Found in version 25.2
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 30664 <at> debbugs.gnu.org (full text, mbox):
> From: omar.antolin <at> 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)
This bug report was last modified 7 years and 169 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.