mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 20:10:47 +00:00
More secure chunk decode adjustment and minor fixes.
This commit is contained in:
parent
28255a2aa2
commit
7bfe665524
15
vlfi.el
15
vlfi.el
@ -47,8 +47,7 @@
|
|||||||
;;; Keep track of file position.
|
;;; Keep track of file position.
|
||||||
(defvar vlfi-start-pos 0
|
(defvar vlfi-start-pos 0
|
||||||
"Absolute position of the visible chunk start.")
|
"Absolute position of the visible chunk start.")
|
||||||
(defvar vlfi-end-pos vlfi-batch-size
|
(defvar vlfi-end-pos 0 "Absolute position of the visible chunk end.")
|
||||||
"Absolute position of the visible chunk end.")
|
|
||||||
(defvar vlfi-file-size 0 "Total size of presented file.")
|
(defvar vlfi-file-size 0 "Total size of presented file.")
|
||||||
|
|
||||||
(defvar vlfi-mode-map
|
(defvar vlfi-mode-map
|
||||||
@ -97,10 +96,10 @@ buffer. You can customize number of bytes displayed by customizing
|
|||||||
`vlfi-batch-size'."
|
`vlfi-batch-size'."
|
||||||
(interactive "fFile to open: ")
|
(interactive "fFile to open: ")
|
||||||
(with-current-buffer (generate-new-buffer "*vlfi*")
|
(with-current-buffer (generate-new-buffer "*vlfi*")
|
||||||
|
(vlfi-mode)
|
||||||
(setq buffer-file-name file
|
(setq buffer-file-name file
|
||||||
vlfi-file-size (vlfi-get-file-size file))
|
vlfi-file-size (vlfi-get-file-size file))
|
||||||
(vlfi-insert-file)
|
(vlfi-insert-file)
|
||||||
(vlfi-mode)
|
|
||||||
(switch-to-buffer (current-buffer))))
|
(switch-to-buffer (current-buffer))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@ -350,15 +349,17 @@ When given MINIMAL flag, skip non important operations."
|
|||||||
(defun vlfi-adjust-chunk ()
|
(defun vlfi-adjust-chunk ()
|
||||||
"Adjust chunk beginning until content can be properly decoded.
|
"Adjust chunk beginning until content can be properly decoded.
|
||||||
Return number of bytes moved back for this to happen."
|
Return number of bytes moved back for this to happen."
|
||||||
(let ((shift 0))
|
(let ((shift 0)
|
||||||
|
(chunk-size (- vlfi-end-pos vlfi-start-pos)))
|
||||||
(while (and (not (zerop vlfi-start-pos))
|
(while (and (not (zerop vlfi-start-pos))
|
||||||
(< shift 3)
|
(< shift 4)
|
||||||
(/= (- vlfi-end-pos vlfi-start-pos)
|
(/= chunk-size
|
||||||
(length (encode-coding-region
|
(length (encode-coding-region
|
||||||
(point-min) (point-max)
|
(point-min) (point-max)
|
||||||
buffer-file-coding-system t))))
|
buffer-file-coding-system t))))
|
||||||
(setq shift (1+ shift)
|
(setq shift (1+ shift)
|
||||||
vlfi-start-pos (1- vlfi-start-pos))
|
vlfi-start-pos (1- vlfi-start-pos)
|
||||||
|
chunk-size (1+ chunk-size))
|
||||||
(let ((inhibit-read-only t))
|
(let ((inhibit-read-only t))
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(insert-file-contents buffer-file-name nil
|
(insert-file-contents buffer-file-name nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user