mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Fix error in tramp-sh-handle-insert-directory
* lisp/net/tramp-sh.el (tramp-sh-handle-insert-directory): Let buffer be unibyte when applying numbers returned with the ls --dired option. Reported by Justus Piater <Justus-dev@Piater.name>. * test/lisp/net/tramp-tests.el (tramp--test-check-files): Extend test.
This commit is contained in:
parent
56556b5f4d
commit
f5a1315f1e
2 changed files with 22 additions and 3 deletions
|
|
@ -2672,7 +2672,8 @@ The method used must be an out-of-band method."
|
|||
(tramp-get-remote-null-device v))))
|
||||
|
||||
(save-restriction
|
||||
(let ((beg (point)))
|
||||
(let ((beg (point))
|
||||
(emc enable-multibyte-characters))
|
||||
(narrow-to-region (point) (point))
|
||||
;; We cannot use `insert-buffer-substring' because the Tramp
|
||||
;; buffer changes its contents before insertion due to calling
|
||||
|
|
@ -2681,7 +2682,9 @@ The method used must be an out-of-band method."
|
|||
(with-current-buffer (tramp-get-buffer v)
|
||||
(buffer-string)))
|
||||
|
||||
;; Check for "--dired" output.
|
||||
;; Check for "--dired" output. We must enable unibyte
|
||||
;; strings, because the "--dired" output counts in bytes.
|
||||
(set-buffer-multibyte nil)
|
||||
(forward-line -2)
|
||||
(when (looking-at-p "//SUBDIRED//")
|
||||
(forward-line -1))
|
||||
|
|
@ -2701,6 +2704,8 @@ The method used must be an out-of-band method."
|
|||
(while (looking-at "//")
|
||||
(forward-line 1)
|
||||
(delete-region (match-beginning 0) (point)))
|
||||
;; Reset multibyte if needed.
|
||||
(set-buffer-multibyte emc)
|
||||
|
||||
;; Some busyboxes are reluctant to discard colors.
|
||||
(unless
|
||||
|
|
|
|||
|
|
@ -5787,7 +5787,8 @@ This requires restrictions of file name syntax."
|
|||
(tmp-name2 (tramp--test-make-temp-name 'local quoted))
|
||||
(files (delq nil files))
|
||||
(process-environment process-environment)
|
||||
(sorted-files (sort (copy-sequence files) #'string-lessp)))
|
||||
(sorted-files (sort (copy-sequence files) #'string-lessp))
|
||||
buffer)
|
||||
(unwind-protect
|
||||
(progn
|
||||
(make-directory tmp-name1)
|
||||
|
|
@ -5849,6 +5850,18 @@ This requires restrictions of file name syntax."
|
|||
tmp-name2 nil directory-files-no-dot-files-regexp))
|
||||
sorted-files))
|
||||
|
||||
;; Check, that `insert-directory' works properly.
|
||||
(with-current-buffer
|
||||
(setq buffer (dired-noselect tmp-name1 "--dired -al"))
|
||||
(goto-char (point-min))
|
||||
(while (not (eobp))
|
||||
(when-let ((name (dired-get-filename 'localp 'no-error)))
|
||||
(unless
|
||||
(string-match-p name directory-files-no-dot-files-regexp)
|
||||
(should (member name files))))
|
||||
(forward-line 1)))
|
||||
(kill-buffer buffer)
|
||||
|
||||
;; `substitute-in-file-name' could return different
|
||||
;; values. For `adb', there could be strange file
|
||||
;; permissions preventing overwriting a file. We don't
|
||||
|
|
@ -5944,6 +5957,7 @@ This requires restrictions of file name syntax."
|
|||
(regexp-quote (getenv envvar))))))))))
|
||||
|
||||
;; Cleanup.
|
||||
(ignore-errors (kill-buffer buffer))
|
||||
(ignore-errors (delete-directory tmp-name1 'recursive))
|
||||
(ignore-errors (delete-directory tmp-name2 'recursive))))))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue