Mercurial > emacs
changeset 102525:438d27553e81
(tar-header-block-tokenize): Presume less, check more.
(tar-summarize-buffer): Don't silently skip incomplete headers.
(tar-mode): Revert to fundamental-mode in case of malformed tar data.
(tar-extract): Try to make sure set-auto-mode doesn't mistakenly
treat a tar file member as being a tar file itself, just because
its own filename includes the parent tar file's.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 13 Mar 2009 15:37:03 +0000 |
parents | cec89dff31fa |
children | bd6dbfa9026f |
files | lisp/ChangeLog lisp/tar-mode.el |
diffstat | 2 files changed, 29 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Fri Mar 13 15:21:04 2009 +0000 +++ b/lisp/ChangeLog Fri Mar 13 15:37:03 2009 +0000 @@ -1,3 +1,12 @@ +2009-03-13 Stefan Monnier <monnier@iro.umontreal.ca> + + * tar-mode.el (tar-header-block-tokenize): Presume less, check more. + (tar-summarize-buffer): Don't silently skip incomplete headers. + (tar-mode): Revert to fundamental-mode in case of malformed tar data. + (tar-extract): Try to make sure set-auto-mode doesn't mistakenly + treat a tar file member as being a tar file itself, just because + its own filename includes the parent tar file's. + 2009-03-13 Kenichi Handa <handa@m17n.org> * international/mule-diag.el (print-fontset): Handling of the
--- a/lisp/tar-mode.el Fri Mar 13 15:21:04 2009 +0000 +++ b/lisp/tar-mode.el Fri Mar 13 15:37:03 2009 +0000 @@ -226,7 +226,7 @@ "Return a `tar-header' structure. This is a list of name, mode, uid, gid, size, write-date, checksum, link-type, and link-name." - (assert (<= (+ pos 512) (point-max))) + (if (> (+ pos 512) (point-max)) (error "Malformed Tar header")) (assert (zerop (mod (- pos (point-min)) 512))) (assert (not enable-multibyte-characters)) (let ((string (buffer-substring pos (setq pos (+ pos 512))))) @@ -483,7 +483,7 @@ (point-min) (point-max)))) descriptor) (with-current-buffer tar-data-buffer - (while (and (<= (+ pos 512) (point-max)) + (while (and (< pos (point-max)) (setq descriptor (tar-header-block-tokenize pos coding))) (let ((size (tar-header-size descriptor))) (if (< size 0) @@ -654,9 +654,17 @@ (generate-new-buffer (format " *tar-data %s*" (file-name-nondirectory (or buffer-file-name (buffer-name)))))) - (tar-swap-data) - (tar-summarize-buffer) - (tar-next-line 0)) + (condition-case err + (progn + (tar-swap-data) + (tar-summarize-buffer) + (tar-next-line 0)) + (error + ;; If summarizing caused an error, then maybe the buffer doesn't contain + ;; tar data. Rather than show a mysterious empty buffer, let's + ;; revert to fundamental-mode. + (fundamental-mode) + (signal (car err) (cdr err))))) (defun tar-subfile-mode (p) @@ -773,7 +781,13 @@ (read-only-p (or buffer-read-only view-p)) (new-buffer-file-name (expand-file-name ;; `:' is not allowed on Windows - (concat tarname "!" name))) + (concat tarname "!" + (if (string-match "/" name) + name + ;; Make sure `name' contains a / + ;; so set-auto-mode doesn't try + ;; to look at `tarname' for hints. + (concat "./" name))))) (buffer (get-file-buffer new-buffer-file-name)) (just-created nil) undo-list)