Subject: bug#37236: 25.1; dired fails on pCloud drive

From: Eli Zaretskii <[email-masked]>
Date: Fri, 30 Aug 2019 18:20:48 +0300

> From: Damon Permezel <[email-masked]>
> Date: Fri, 30 Aug 2019 18:14:03 +1000
> 
> M-x dired ~/pCloud\ Drive
> 
> Debugger entered--Lisp error: (wrong-type-argument consp nil)
>   ls-lisp-sanitize(((".VolumeIcon.icns" nil 1 "dap" "wheel" (23900 56314 0 0) (23900 56314 0 0) (23900 56314 0 0) 1708546 "-r--r--r--" t 53210 855638019) (".DS_Store" nil 1 "dap" "staff" (23911 33443 0 0) (23911 33443 0 0) (23911 33443 0 0) 8196 "-rw-r--r--" t 53136 855638019) ("Getting started with pCloud.pdf" nil 1 "dap" "staff" (23894 11575 0 0) (23894 11575 0 0) (23894 11575 0 0) 22442353 "-rw-r--r--" t 53209 855638019) ("Public Folder" t 2 "dap" "staff" (23911 34577 0 0) (23911 34577 0 0) (23911 34577 0 0) 4096 "drwxr-xr-x" t 53208 855638019) ("Crypto Folder" t 3 "dap" "staff" (23912 55020 0 0) (23912 55020 0 0) (23912 55020 0 0) 4096 "drwxr-xr-x" t 53112 855638019) ("CryptoMator" t 3 "dap" "staff" (23899 61629 0 0) (23899 61629 0 0) (23899 61629 0 0) 4096 "drwxr-xr-x" t 53107 855638019) ("rclone" t 5 "dap" "staff" (23894 12721 0 0) (23894 12721 0 0) (23894 12721 0 0) 4096 "drwxr-xr-x" t 308 855638019) ("My Videos" t 2 "dap" "staff" (23894 11575 0 0) (23894 11575 0 0) (23894 11575 0 0) 4096 "drwxr-xr-x" t 53207 855638019) ("My Pictures" t 2 "dap" "staff" (23894 11575 0 0) (23894 11575 0 0) (23894 11575 0 0) 4096 "drwxr-xr-x" t 53206 855638019) ("My Music" t 2 "dap" "staff" (23894 11575 0 0) (23894 11575 0 0) (23894 11575 0 0) 4096 "drwxr-xr-x" t 53205 855638019) ("." t 9 "dap" "staff" (23911 34577 0 0) (23911 34577 0 0) (23911 34577 0 0) 4096 "drwxr-xr-x" t 1 855638019)))
>   ls-lisp-insert-directory("/Users/dap/pCloud Drive/" (97 108) nil nil t)
>   ls-lisp--insert-directory(#[...

ls-lisp isn't prepared for a situation where a directory has a "."
entry, but doesn't have a ".." entry.

Does the patch below fix the problem?

diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index e802c24..8491181 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -517,7 +517,8 @@ ls-lisp-sanitize
 are copied from the \".\" entry, if they are non-nil.  Otherwise,
 the offending element is removed from the list, as are any
 elements for other directory entries with nil attributes."
-  (if (and (null (cdr (assoc ".." file-alist)))
+  (if (and (consp (assoc ".." file-alist))
+           (null (cdr (assoc ".." file-alist)))
 	   (cdr (assoc "." file-alist)))
       (setcdr (assoc ".." file-alist) (cdr (assoc "." file-alist))))
   (rassq-delete-all nil file-alist))