1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Tramp: Handle hops with "%" in their names

* lisp/net/tramp.el (tramp-dissect-file-name, tramp-compute-multi-hops):
Handle hops with "%" in their names, like USER%DOMAIN or POD%NAMESPACE.
This commit is contained in:
Michael Albinus 2024-07-26 22:10:36 +02:00
parent 4e250154ec
commit d7665595f7

View file

@ -1770,16 +1770,22 @@ default values are used."
(unless nodefault (unless nodefault
(when hop (when hop
(setq v (tramp-dissect-hop-name hop) (setq v (tramp-dissect-hop-name hop)
hop (and hop (tramp-make-tramp-hop-name v)))) hop (tramp-make-tramp-hop-name v)))
(let ((tramp-default-host (let ((tramp-default-host
(or (and v (not (string-search "%h" (tramp-file-name-host v))) (or (and v (not (string-search "%h" (tramp-file-name-host v)))
(tramp-file-name-host v)) (tramp-file-name-host v))
tramp-default-host))) tramp-default-host)))
(setq method (tramp-find-method method user host) (setq method (tramp-find-method method user host)
user (tramp-find-user method user host) user (tramp-find-user method user host)
host (tramp-find-host method user host) host (tramp-find-host method user host))
(when hop
;; Replace placeholders. The hop could contain "%"
;; which is not intended as format character, for
;; example in USER%DOMAIN or POD%NAMESPACE.
(setq hop
(replace-regexp-in-string
(rx "%" (group (= 2 alnum))) "%%\\1" hop)
hop hop
(and hop
(format-spec hop (format-spec-make ?h host ?u user)))))) (format-spec hop (format-spec-make ?h host ?u user))))))
;; Return result. ;; Return result.
@ -4930,8 +4936,13 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
(if (null proxy) (if (null proxy)
;; No more hops needed. ;; No more hops needed.
(setq choices nil) (setq choices nil)
;; Replace placeholders. ;; Replace placeholders. The proxy could contain "%" which
;; is not intended as format character, for example in
;; USER%DOMAIN or POD%NAMESPACE.
(setq proxy (setq proxy
(replace-regexp-in-string
(rx "%" (group (= 2 alnum))) "%%\\1" proxy)
proxy
(format-spec (format-spec
proxy proxy
(format-spec-make (format-spec-make