* bug#22333: 24.5; EWW downloads invalid compressed tar-files
@ 2016-01-08 21:23 Iñigo Serna
2016-01-09 6:50 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Iñigo Serna @ 2016-01-08 21:23 UTC (permalink / raw)
To: 22333
Hello,
Browsing web using eww and downloading compressed tar-files
(f.e. filename.tar.gz) save invalid files (can't be uncompressed).
I've tested on emacs 24.5 official packages both in Fedora 23 (x86_64)
and ArchLinux (x86_64 and arm), running with "emacs -Q -nw".
Tried also on git master, but download fails with this message:
error in process filter: Args out of range: #<buffer *http pypi.python.org:443*>, 0, 13
To reproduce, browse to any web which offers any tar compressed file
and hit 'd' to download when cursor is over file URL. Then try to
uncompress it:
/home/inigo/Downloads ⚡ tar xvf filename.tar.gz
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
I see `eww-download` calls `url-retrieve` to download the file
asynchronously, which stores the downloaded file in an emacs buffer and
then saves it.
I think the problem comes from the buffer saving action and not from eww
code, but I don't have enough skills to debug this.
Btw, using `url-copy-file` (which does not employ an intermediate emacs
buffer) works ok, so I use this code:
(defun isr/eww-download ()
"Alternative not asynchronous download."
(interactive)
(let ((url (get-text-property (point) 'shr-url)))
(unless url
(message "No URL under point"))
(url-copy-file url (concat eww-download-directory "/" (file-name-nondirectory url)))
(message "Saved %s" url)))
Thanks,
Iñigo Serna
PS: This is my first emacs bug report, excuse me if I've done something wrongly.
INFORMATION COPIED FROM report-emacs-bug:
Configured using:
`configure --build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu --program-prefix=
--disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
--datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
--libexecdir=/usr/libexec --localstatedir=/var
--sharedstatedir=/var/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
--with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
--with-gpm=no build_alias=x86_64-redhat-linux-gnu
host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
-pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-m64 -mtune=generic' LDFLAGS=-Wl,-z,relro'
Important settings:
value of $LANG: en_GB.UTF-8
locale-coding-system: utf-8-unix
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22333: 24.5; EWW downloads invalid compressed tar-files
2016-01-08 21:23 bug#22333: 24.5; EWW downloads invalid compressed tar-files Iñigo Serna
@ 2016-01-09 6:50 ` Eli Zaretskii
2016-01-09 10:02 ` Andreas Schwab
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2016-01-09 6:50 UTC (permalink / raw)
To: Iñigo Serna; +Cc: 22333
> From: Iñigo Serna <inigoserna@gmail.com>
> Date: Fri, 08 Jan 2016 22:23:27 +0100
>
> Browsing web using eww and downloading compressed tar-files
> (f.e. filename.tar.gz) save invalid files (can't be uncompressed).
>
> I've tested on emacs 24.5 official packages both in Fedora 23 (x86_64)
> and ArchLinux (x86_64 and arm), running with "emacs -Q -nw".
> Tried also on git master, but download fails with this message:
>
> error in process filter: Args out of range: #<buffer *http pypi.python.org:443*>, 0, 13
>
> To reproduce, browse to any web which offers any tar compressed file
> and hit 'd' to download when cursor is over file URL. Then try to
> uncompress it:
>
> /home/inigo/Downloads ⚡ tar xvf filename.tar.gz
> tar: This does not look like a tar archive
> tar: Skipping to next header
> tar: Exiting with failure status due to previous errors
Could it be that the saved tar file is already uncompressed?
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22333: 24.5; EWW downloads invalid compressed tar-files
2016-01-09 6:50 ` Eli Zaretskii
@ 2016-01-09 10:02 ` Andreas Schwab
2016-01-09 11:26 ` Iñigo Serna
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2016-01-09 10:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Iñigo Serna, 22333
Eli Zaretskii <eliz@gnu.org> writes:
>> To reproduce, browse to any web which offers any tar compressed file
>> and hit 'd' to download when cursor is over file URL. Then try to
>> uncompress it:
>>
>> /home/inigo/Downloads ⚡ tar xvf filename.tar.gz
>> tar: This does not look like a tar archive
>> tar: Skipping to next header
>> tar: Exiting with failure status due to previous errors
>
> Could it be that the saved tar file is already uncompressed?
I'd rather guess it's compressed twice.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22333: 24.5; EWW downloads invalid compressed tar-files
2016-01-09 10:02 ` Andreas Schwab
@ 2016-01-09 11:26 ` Iñigo Serna
2016-02-04 4:59 ` Lars Ingebrigtsen
2016-02-04 5:06 ` Lars Ingebrigtsen
0 siblings, 2 replies; 7+ messages in thread
From: Iñigo Serna @ 2016-01-09 11:26 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 22333
Hi and thanks for your time,
Andreas Schwab writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>> Could it be that the saved tar file is already uncompressed?
>
> I'd rather guess it's compressed twice.
I think I've discovered the problem with the downloaded files:
0. As downloaded (remember it's saved from an emacs buffer) is not a
valid .tar.gz file
1. but it is a valid gzipped file
2. the uncompressed file contains some HTTP headers at
the start of the file.
3. After manually removing these lines and changing extension (to add
the '.gz' again), file is correctly recognized as a gzipped tar-file.
[0] /home/inigo/Downloads ⚡ tar xvfz filename.tar.gz
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
[1] /home/inigo/Downloads ⚡ gzip -d filename.tar.gz
/home/inigo/Downloads ⚡ file filename.tar
filename.tar: data
[2] /home/inigo/Downloads ⚡ head -21 filename.tar
HTTP/1.1 200 OK
x-amz-replication-status: COMPLETED
Last-Modified: Sun, 08 Nov 2015 13:11:05 GMT
ETag: "9c13c5fafcb1aecd43f51fa9b0278000"
Content-Type: application/octet-stream
Server: AmazonS3
Via: 1.1 varnish
Fastly-Debug-Digest: 37a3779f444d206796099a174bb873c853bb8f1b9a13cf06f29108f907a9d50b
Cache-Control: max-age=31557600, public
Content-Length: 87341
Accept-Ranges: bytes
Date: Sat, 09 Jan 2016 10:16:29 GMT
Via: 1.1 varnish
Age: 135058
Connection: keep-alive
X-Served-By: cache-sea1920-SEA, cache-fra1247-FRA
X-Cache: HIT, HIT
X-Cache-Hits: 2, 1
X-Timer: S1452334589.874408,VS0,VE1
*I?V.�dist/lfm-3.0.tar��[w۸�0���.�d���H�$;�>:����N�+��c;}9n/
[3] [...remove HTTP headers from first lines of file...]
/home/inigo/Downloads ⚡ file filename.tar
filename.tar: gzip compressed data, was "dist/lfm-3.0.tar", last modified: Sun Nov 8 14:07:54 2015, max compression
/home/inigo/Downloads ⚡ mv filename.tar filename.tar.gz
/home/inigo/Downloads ⚡ file filename.tar.gz
filename.tar.gz: gzip compressed data, was "dist/lfm-3.0.tar", last modified: Sun Nov 8 14:07:54 2015, max compression
/home/inigo/Downloads ⚡ tar xvfz filename.tar.gz
lfm-3.0/
[...]
So I think the error comes with those extra spurious headers added to
the start of the buffer when downloading the file, which mess buffer
saving operation.
The bug can be easily reproduced with code like:
(let ((url "https://pypi.python.org/packages/source/l/lfm/lfm-3.0.1.tar.gz"))
(url-retrieve url 'test-cb (list url)))
(defun test-cb (status url)
(message "Downloaded: %s" url)
;; (sleep-for 60)
(write-file "~/a.tgz")
(message "Saved: %s" url))
`eww-download-callback` (called by `url-retrieve`) should remove those headers
after download is finished and before buffer is saved to disk.
A simple fix could be to add (excuse my poor elisp skills):
(goto-char (point-min))
(search-forward-regexp "^$")
(forward-line)
(delete-region (point-min) (point))
before '(write-file file)' in `eww-download-callback`.
... and this almost works, but the downloaded file is compressed twice
now as Andreas stated (ie, tar.gz is gzipped again at file saving).
Thus it looks there is an additional issue when saving gzipped tar-files
from a buffer.
Any idea on how to solve this?
Thanks,
Iñigo Serna
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22333: 24.5; EWW downloads invalid compressed tar-files
2016-01-09 11:26 ` Iñigo Serna
@ 2016-02-04 4:59 ` Lars Ingebrigtsen
2016-02-04 5:06 ` Lars Ingebrigtsen
1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-04 4:59 UTC (permalink / raw)
To: Iñigo Serna; +Cc: Andreas Schwab, 22333
Iñigo Serna <inigoserna@gmail.com> writes:
> `eww-download-callback` (called by `url-retrieve`) should remove those headers
> after download is finished and before buffer is saved to disk.
>
> A simple fix could be to add (excuse my poor elisp skills):
>
> (goto-char (point-min))
> (search-forward-regexp "^$")
> (forward-line)
> (delete-region (point-min) (point))
>
> before '(write-file file)' in `eww-download-callback`.
This function looks like this in emacs-25:
(defun eww-download-callback (status url)
(unless (plist-get status :error)
(let* ((obj (url-generic-parse-url url))
(path (car (url-path-and-query obj)))
(file (eww-make-unique-file-name
(eww-decode-url-file-name (file-name-nondirectory path))
eww-download-directory)))
(goto-char (point-min))
(re-search-forward "\r?\n\r?\n")
(write-region (point) (point-max) file)
(message "Saved %s" file))))
So it looks like this has already been fixed.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22333: 24.5; EWW downloads invalid compressed tar-files
2016-01-09 11:26 ` Iñigo Serna
2016-02-04 4:59 ` Lars Ingebrigtsen
@ 2016-02-04 5:06 ` Lars Ingebrigtsen
2016-02-06 17:28 ` Iñigo Serna
1 sibling, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-04 5:06 UTC (permalink / raw)
To: Iñigo Serna; +Cc: Andreas Schwab, 22333
Iñigo Serna <inigoserna@gmail.com> writes:
> ... and this almost works, but the downloaded file is compressed twice
> now as Andreas stated (ie, tar.gz is gzipped again at file saving).
And I've confirmed that the files are not double-gzipped when hitting
`d' on links on the following pages:
http://www-ftp.lip6.fr/pub/emacs/gnus/
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-02-06 17:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-08 21:23 bug#22333: 24.5; EWW downloads invalid compressed tar-files Iñigo Serna
2016-01-09 6:50 ` Eli Zaretskii
2016-01-09 10:02 ` Andreas Schwab
2016-01-09 11:26 ` Iñigo Serna
2016-02-04 4:59 ` Lars Ingebrigtsen
2016-02-04 5:06 ` Lars Ingebrigtsen
2016-02-06 17:28 ` Iñigo Serna
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).