Subject: bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly

From: Michael Albinus <[email-masked]>
Date: Sat, 06 Jul 2024 19:00:48 +0200

Michael Albinus <[email-masked]> writes:

Hi,

> (tramp-dissect-file-name "/ssh:[2001::abcd]#2202:/tmp/xxx")
> => (tramp-file-name "ssh" nil nil "2001::abcd#2202" nil "/tmp/xxx" nil)
>
> That is a structure, which has "2001::abcd#2202" as host name. Ouch.
>
> Will see how I could fix it.

Could you please try the appended patch? It ought to fix the problem.

Best regards, Michael.

diff --git a/lisp/tramp.el b/lisp/tramp.el
index f97ed66c..b35c2017 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -1061,7 +1061,10 @@ Derived from `tramp-prefix-port-format'.")

 (defconst tramp-host-with-port-regexp
   (rx
-   (group (regexp tramp-host-regexp))
+   (group (| (regexp tramp-host-regexp)
+	     (: (regexp tramp-prefix-ipv6-regexp)
+		(? (regexp tramp-ipv6-regexp))
+		(regexp tramp-postfix-ipv6-regexp))))
    (regexp tramp-prefix-port-regexp)
    (group (regexp tramp-port-regexp)))
   "Regexp matching host names with port numbers.")