emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 61de292: Fix (Bug#32218). Do not merge with maste


From: Michael Albinus
Subject: [Emacs-diffs] emacs-26 61de292: Fix (Bug#32218). Do not merge with master
Date: Fri, 20 Jul 2018 04:56:50 -0400 (EDT)

branch: emacs-26
commit 61de292c72382403633f753c3d632a560ccfee98
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Fix (Bug#32218).  Do not merge with master
    
    * doc/misc/trampver.texi:
    * lisp/net/trampver.el: Change version to "2.3.4.26.2".
    (customize-package-emacs-version-alist): Add Tramp version
    integrated in Emacs 26.2.
    
    * lisp/net/tramp.el (tramp-handle-file-truename):
    * lisp/net/tramp-adb.el (tramp-adb-handle-file-truename):
    * lisp/net/tramp-sh.el (tramp-sh-handle-file-truename): Fix problem
    with trailing slash.  (Bug#32218)
    
    * test/lisp/net/tramp-tests.el (tramp-test21-file-links):
    Remove `tramp--test-emacs27-p' check.
---
 doc/misc/trampver.texi       |  2 +-
 lisp/net/tramp-adb.el        | 25 ++++++++++++++++++-------
 lisp/net/tramp-sh.el         | 11 +++++------
 lisp/net/tramp.el            | 28 +++++++++++++---------------
 lisp/net/trampver.el         |  8 ++++----
 test/lisp/net/tramp-tests.el |  5 +----
 6 files changed, 42 insertions(+), 37 deletions(-)

diff --git a/doc/misc/trampver.texi b/doc/misc/trampver.texi
index 0970e4e..c6473f5 100644
--- a/doc/misc/trampver.texi
+++ b/doc/misc/trampver.texi
@@ -8,7 +8,7 @@
 @c In the Tramp GIT, the version number is auto-frobbed from
 @c configure.ac, so you should edit that file and run
 @c "autoconf && ./configure" to change the version number.
address@hidden trampver 2.3.4
address@hidden trampver 2.3.4.26.2
 
 @c Other flags from configuration
 @set instprefix /usr/local
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 58f748b..0576cbe 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -281,13 +281,16 @@ pass to the OPERATION."
 ;; code could be shared?
 (defun tramp-adb-handle-file-truename (filename)
   "Like `file-truename' for Tramp files."
-  (format
-   "%s%s"
+   ;; Preserve trailing "/".
+  (funcall
+   (if (string-equal (file-name-nondirectory filename) "")
+       'file-name-as-directory 'identity)
    (with-parsed-tramp-file-name (expand-file-name filename) nil
      (tramp-make-tramp-file-name
       method user domain host port
       (with-tramp-file-property v localname "file-truename"
-       (let ((result nil))                     ; result steps in reverse order
+       (let ((result nil)                      ; result steps in reverse order
+             (quoted (tramp-compat-file-name-quoted-p localname)))
          (tramp-message v 4 "Finding true name for `%s'" filename)
          (let* ((steps (split-string localname "/" 'omit))
                 (localnamedir (tramp-run-real-handler
@@ -359,11 +362,19 @@ pass to the OPERATION."
                                  (not (string= (substring result -1) "/"))))
              (setq result (concat result "/"))))
 
+         ;; Detect cycle.
+         (when (and (file-symlink-p filename)
+                    (string-equal result localname))
+           (tramp-error
+            v 'file-error
+            "Apparent cycle of symbolic links for %s" filename))
+         ;; If the resulting localname looks remote, we must quote it
+         ;; for security reasons.
+         (when (or quoted (file-remote-p result))
+           (let (file-name-handler-alist)
+             (setq result (tramp-compat-file-name-quote result))))
          (tramp-message v 4 "True name of `%s' is `%s'" localname result)
-         result))))
-
-   ;; Preserve trailing "/".
-   (if (string-equal (file-name-nondirectory filename) "") "/" "")))
+         result))))))
 
 (defun tramp-adb-handle-file-attributes (filename &optional id-format)
   "Like `file-attributes' for Tramp files."
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 212be4f..3f83697 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1118,8 +1118,10 @@ component is used as the target of the symlink."
 
 (defun tramp-sh-handle-file-truename (filename)
   "Like `file-truename' for Tramp files."
-  (format
-   "%s%s"
+   ;; Preserve trailing "/".
+  (funcall
+   (if (string-equal (file-name-nondirectory filename) "")
+       'file-name-as-directory 'identity)
    (with-parsed-tramp-file-name (expand-file-name filename) nil
      (tramp-make-tramp-file-name
       method user domain host port
@@ -1223,10 +1225,7 @@ component is used as the target of the symlink."
            (let (file-name-handler-alist)
              (setq result (tramp-compat-file-name-quote result))))
          (tramp-message v 4 "True name of `%s' is `%s'" localname result)
-         result))))
-
-   ;; Preserve trailing "/".
-   (if (string-equal (file-name-nondirectory filename) "") "/" "")))
+         result))))))
 
 ;; Basic functions.
 
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 59f4cea..1344757 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3153,17 +3153,18 @@ User is always nil."
 
 (defun tramp-handle-file-truename (filename)
   "Like `file-truename' for Tramp files."
-  (let ((result (expand-file-name filename))
-       (numchase 0)
-       ;; Don't make the following value larger than
-       ;; necessary.  People expect an error message in a
-       ;; timely fashion when something is wrong;
-       ;; otherwise they might think that Emacs is hung.
-       ;; Of course, correctness has to come first.
-       (numchase-limit 20)
-       symlink-target)
-    (format
-     "%s%s"
+  ;; Preserve trailing "/".
+  (funcall
+   (if (string-equal (file-name-nondirectory filename) "")
+       'file-name-as-directory 'identity)
+   (let ((result (expand-file-name filename))
+        (numchase 0)
+        ;; Don't make the following value larger than necessary.
+        ;; People expect an error message in a timely fashion when
+        ;; something is wrong; otherwise they might think that Emacs
+        ;; is hung.  Of course, correctness has to come first.
+        (numchase-limit 20)
+        symlink-target)
      (with-parsed-tramp-file-name result v1
        (with-tramp-file-property v1 v1-localname "file-truename"
         (while (and (setq symlink-target (file-symlink-p result))
@@ -3188,10 +3189,7 @@ User is always nil."
             (tramp-error
              v1 'file-error
              "Maximum number (%d) of symlinks exceeded" numchase-limit)))
-        (directory-file-name result)))
-
-     ;; Preserve trailing "/".
-     (if (string-equal (file-name-nondirectory filename) "") "/" ""))))
+        (directory-file-name result))))))
 
 (defun tramp-handle-find-backup-file-name (filename)
   "Like `find-backup-file-name' for Tramp files."
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index d02e6bc..6454b5b 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -7,7 +7,7 @@
 ;; Maintainer: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
 ;; Package: tramp
-;; Version: 2.3.4
+;; Version: 2.3.4.26.2
 
 ;; This file is part of GNU Emacs.
 
@@ -33,7 +33,7 @@
 ;; should be changed only there.
 
 ;;;###tramp-autoload
-(defconst tramp-version "2.3.4"
+(defconst tramp-version "2.3.4.26.2"
   "This version of Tramp.")
 
 ;;;###tramp-autoload
@@ -55,7 +55,7 @@
 ;; Check for Emacs version.
 (let ((x (if (>= emacs-major-version 24)
     "ok"
-  (format "Tramp 2.3.4 is not fit for %s"
+  (format "Tramp 2.3.4.26.2 is not fit for %s"
          (when (string-match "^.*$" (emacs-version))
            (match-string 0 (emacs-version)))))))
   (unless (string-match "\\`ok\\'" x) (error "%s" x)))
@@ -70,7 +70,7 @@
         ("2.2.9-24.4" . "24.4") ("2.2.11-24.5" . "24.5")
         ("2.2.13.25.1" . "25.1") ("2.2.13.25.2" . "25.2")
         ("2.2.13.25.2" . "25.3")
-        ("2.3.3.26.1" . "26.1")))
+        ("2.3.3.26.1" . "26.1") ("2.3.4.26.2" . "26.2")))
 
 (add-hook 'tramp-unload-hook
          (lambda ()
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index e70f00e..8f81081 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2855,10 +2855,7 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
              ;; We must unquote it.
              (should
               (string-equal
-               (funcall
-                (if (tramp--test-emacs27-p)
-                    'tramp-compat-file-name-unquote 'identity)
-                (file-truename tmp-name1))
+               (file-truename tmp-name1)
                (tramp-compat-file-name-unquote (file-truename tmp-name3))))))
 
        ;; Cleanup.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]