From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly Date: Sun, 07 Jul 2024 12:28:45 +0200 Message-ID: <87v81hzeaq.fsf@gmx.de> References: <87bk3a1s3f.fsf@gmx.de> <871q461mm7.fsf@gmx.de> Reply-To: Michael Albinus Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12858"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 71972@debbugs.gnu.org To: Yikai Zhao Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 07 12:30:35 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sQPAB-0003Bq-CD for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Jul 2024 12:30:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQP9e-0006Vx-Fh; Sun, 07 Jul 2024 06:30:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQP9a-0006Sx-J5 for bug-gnu-emacs@gnu.org; Sun, 07 Jul 2024 06:29:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQP9a-0005Qv-As for bug-gnu-emacs@gnu.org; Sun, 07 Jul 2024 06:29:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sQP9e-0005W0-8L for bug-gnu-emacs@gnu.org; Sun, 07 Jul 2024 06:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Jul 2024 10:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71972 X-GNU-PR-Package: emacs Original-Received: via spool by 71972-submit@debbugs.gnu.org id=B71972.172034814321072 (code B ref 71972); Sun, 07 Jul 2024 10:30:02 +0000 Original-Received: (at 71972) by debbugs.gnu.org; 7 Jul 2024 10:29:03 +0000 Original-Received: from localhost ([127.0.0.1]:47454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sQP8g-0005Tn-OW for submit@debbugs.gnu.org; Sun, 07 Jul 2024 06:29:03 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:43625) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sQP8f-0005TH-4V for 71972@debbugs.gnu.org; Sun, 07 Jul 2024 06:29:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1720348128; x=1720952928; i=michael.albinus@gmx.de; bh=9qL0kiIzwIZcKDfr9duviZCjqzN54++MFMLi8b8vCW4=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=SNFjwo/4RXFHWY6iL/WbBmKh6LObHsmyDLxRE6/uzOFlM+20RqNavZoVD8h5GEQM O74aVxQKCwlkIQUNAIyB+r4RrpyBq7GiAX5rlXcGQsd62csI8wFamtSlbCzbq8ULd Xgbc1rOxZqLOCXav1JyuvQoYGWIfi9OZwLV5Wgpm4HJ+jJBb6nQNcjOqqd+VWxti3 jnIvE5k0bwazAZkwATcGy40rIIQmEkjFpbCHpIG5wGh1R3Buh0XL5UXNklEz6roMh kc7A/KJxdBmlQnJH4I6ZUdNRzqAWq9Kjab48CGrhkNzBn95ag0J4oHwLYV5zO8o+k bisKUKSiEsWajlYNhA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MhD2Y-1rvDFF3gSw-00g7CI; Sun, 07 Jul 2024 12:28:47 +0200 In-Reply-To: (Yikai Zhao's message of "Sun, 7 Jul 2024 14:31:13 +0800") X-Provags-ID: V03:K1:v003HLFUuw7xnPJaykRL8WMBZ4U2AuxkoNDbkMSm99qWdjzQR8H +BDNqlUPpfdP2CE/OgyIx+3Coygmt1YutAqkgqOtQnTwB5p1dDSmzPphW2Sba3S2e1z1PRP r+ByzyvjlEU+H7eAsmK3nUPaQx9kyGK/lvg2tpibbbgCvOyooFoZqmvXNNbdGnoXQ+Gcxr7 oJ5hkDMqYJEMfzzuFHa4w== UI-OutboundReport: notjunk:1;M01:P0:XaRYDRrSgQM=;6NP+kctK6uKhIx1blqCZPhQ3OcH TFp9pcxc/U3LiQnO3vXXGvvNRl2pOJPZBABEVy/d4kDmbdo3k/DIU4o4ze/j6tH/8sVXa0Xv7 m37zbB8ChG1ayfRdKD0R0Ou5fbOK3fVir6l0HKBRnkqLKEh4hP/SS8Vf31y+UY18p8p5Kkkj0 wbYGkmLQkzMEh+Kp+zQiHMyZrfP7zKhrsFsHoGiJhjIZadbxk4vb9Vf9LtSI8upKiEcXJeLi5 hphyGgf6SfX2h9WBCS9DzWguaXe7pLCaXeZ7jEKyuIzt+PxS+OroagLS+0Ab9uKeLK/bBcPdo R6o0a46m5EaeiqIaxTJfaXXmrjOyAk0UBx6f2LeHaYXDWvSGOvn7J5GOgoh2Cm1e+H0VGQuOI opEHwGX3KJH6Mirc8bCaaEI0KlDUa8gkG/hvvZTRKj4eEog5hGaYthmeWpk7Yr8SOpifeX4Cg C9E0U/ANkcD+WvcCvS4od/rdMqBPgKL8eafOyK5vo4/UpLJzN40sQuPr7a0VcDNisLcFPKBJI V/17rQoV4MYXHhduaiFB47tbkRK6dM9toDRw5eoygWLN9sXz4Q058+CqryFaH4+BPAUifsK0K nga/YygUNN5X7jobmDUhhGt1gqAaPXPyYmBtIIQdM00VHD3/qYGhzsICfGvcCMoTQi1AGXaZ1 K7giUqfFsvBBHBo9pziI94BE0tbFFbjp2s9ztU5fj+QrS4BBkob3oEPaGoz5YwyVHE835Rqzh Yrj2TMMwE5OtzYZSv58D3kFbIMxAgiVvxYfWwjNkYtqCglTJdLIWFzN2SzrSmPj+nFAMZE4A X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288554 Archived-At: --=-=-= Content-Type: text/plain Yikai Zhao writes: > Hi, Hi, > Thanks for the patch. However, with this patch applied to master, the result is: > > (tramp-dissect-file-name "/ssh:[2001::abcd]#2202:/tmp/xxx") > => (tramp-file-name "ssh" nil nil #("Oldtown" 0 7 (tramp-default t)) > "2202" "/tmp/xxx" nil) [2 times] > > ("oldtown" is my local hostname). Although the port is correctly > parsed, the host is now incorrect. Indeed, we have a race condition. tramp-host-with-port-regexp is defined before tramp-set-syntax has run. Could you, please, try the appended patch indeed? > Also note that in master, the correct file path for tramp.el is > lisp/net/tramp.el, so I had to manually edit your patch before > applying it. What version is your patch based on? Maybe the result is > different in different versions? I develop in the Tramp git repo. The files are identical with the ones in the Emacs git repo. However, there is a different directory structure. Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/tramp.el b/lisp/tramp.el index f97ed66c..f960b1a3 100644 =2D-- a/lisp/tramp.el +++ b/lisp/tramp.el @@ -78,6 +78,7 @@ (defvar tramp-postfix-ipv6-regexp) (defvar tramp-postfix-host-format) (defvar tramp-postfix-host-regexp) +(defvar tramp-host-with-port-regexp) (defvar tramp-remote-file-name-spec-regexp) (defvar tramp-file-name-structure) (defvar tramp-file-name-regexp) @@ -878,6 +879,7 @@ to be set, depending on VALUE." tramp-postfix-ipv6-regexp (tramp-build-postfix-ipv6-regexp) tramp-postfix-host-format (tramp-build-postfix-host-format) tramp-postfix-host-regexp (tramp-build-postfix-host-regexp) + tramp-host-with-port-regexp (tramp-build-host-with-port-regexp) tramp-remote-file-name-spec-regexp (tramp-build-remote-file-name-spec-regexp) tramp-file-name-structure (tramp-build-file-name-structure) @@ -1059,11 +1061,18 @@ Derived from `tramp-prefix-port-format'.") (defconst tramp-port-regexp (rx (+ digit)) "Regexp matching port numbers.") -(defconst tramp-host-with-port-regexp +(defun tramp-build-host-with-port-regexp () + "Return `tramp-host-with-port-regexp'." (rx - (group (regexp tramp-host-regexp)) + (group (| (regexp tramp-host-regexp) + (: (regexp (tramp-build-prefix-ipv6-regexp)) + (? (regexp tramp-ipv6-regexp)) + (regexp (tramp-build-postfix-ipv6-regexp))))) (regexp tramp-prefix-port-regexp) - (group (regexp tramp-port-regexp))) + (group (regexp tramp-port-regexp)))) + +(defvar tramp-host-with-port-regexp + nil ; Initialized when defining `tramp-syntax'! "Regexp matching host names with port numbers.") (defconst tramp-postfix-hop-format "|" --=-=-=--