From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Yikai Zhao <yikai@z1k.dev>
Cc: 71972@debbugs.gnu.org
Subject: bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly
Date: Sun, 07 Jul 2024 12:28:45 +0200 [thread overview]
Message-ID: <87v81hzeaq.fsf@gmx.de> (raw)
In-Reply-To: <CANMyjpi2nz3iOZM7_6G+kBEHbJa9O9wX_2iDXLbfpiH2O1m49g@mail.gmail.com> (Yikai Zhao's message of "Sun, 7 Jul 2024 14:31:13 +0800")
[-- Attachment #1: Type: text/plain, Size: 975 bytes --]
Yikai Zhao <yikai@z1k.dev> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1682 bytes --]
diff --git a/lisp/tramp.el b/lisp/tramp.el
index f97ed66c..f960b1a3 100644
--- 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 "|"
next prev parent reply other threads:[~2024-07-07 10:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-06 12:22 bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly Yikai Zhao
2024-07-06 15:02 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-06 17:00 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-07 6:31 ` Yikai Zhao
2024-07-07 10:28 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-07-07 15:56 ` Yikai Zhao
2024-07-07 17:47 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v81hzeaq.fsf@gmx.de \
--to=bug-gnu-emacs@gnu.org \
--cc=71972@debbugs.gnu.org \
--cc=michael.albinus@gmx.de \
--cc=yikai@z1k.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).