Fix detection of Dired with files whose name ends in a colon

* lisp/dired.el (dired-build-subdir-alist): Use a more general
regexp to detect file entries whose names end in a colon, when
various non-default 'ls' switches are used.  (Bug#78493)
This commit is contained in:
Eli Zaretskii 2025-05-24 16:25:34 +03:00
parent 056ba8c569
commit 463787c4e9

View file

@ -3721,7 +3721,13 @@ instead of `dired-actual-switches'."
;; ange-ftp listings. ;; ange-ftp listings.
(and (dired-switches-recursive-p switches) (and (dired-switches-recursive-p switches)
(string-match "\\`/.*:\\(/.*\\)" default-directory) (string-match "\\`/.*:\\(/.*\\)" default-directory)
(concat "\\`" (match-string 1 default-directory))))) (concat "\\`" (match-string 1 default-directory))))
;; Regexp that describes the beginning of line of a
;; file/directory entry (as opposed to a subdirectory
;; heading), including the optional mark, inode, and size.
(file-entry-beg-re (concat dired-re-maybe-mark
dired-re-inode-size
dired-re-perms)))
(goto-char (point-min)) (goto-char (point-min))
(setq dired-subdir-alist nil) (setq dired-subdir-alist nil)
(while (re-search-forward dired-subdir-regexp nil t) (while (re-search-forward dired-subdir-regexp nil t)
@ -3730,8 +3736,7 @@ instead of `dired-actual-switches'."
(unless (save-excursion (unless (save-excursion
(goto-char (match-beginning 0)) (goto-char (match-beginning 0))
(beginning-of-line) (beginning-of-line)
(forward-char 2) (looking-at-p file-entry-beg-re))
(looking-at-p dired-re-perms))
(save-excursion (save-excursion
(goto-char (match-beginning 1)) (goto-char (match-beginning 1))
(setq new-dir-name (setq new-dir-name