all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly
@ 2024-07-06 12:22 Yikai Zhao
  2024-07-06 15:02 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Yikai Zhao @ 2024-07-06 12:22 UTC (permalink / raw
  To: 71972


To reproduce:

  (tramp-dissect-file-name "/ssh:[2001::abcd]#2202:/tmp/xxx")

Expected result: the result "port" should be "2202"

Current result: the result "port" is empty

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.22.30, cairo version 1.15.10) of 2024-07-06 built on a40438a00efa
Repository revision: bd86a6c4fde1aa42ea9e8b5434f0cb63f8d52684
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: Gentoo Linux






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-06 15:02 UTC (permalink / raw
  To: Yikai Zhao; +Cc: 71972

Yikai Zhao <yikai@z1k.dev> writes:

Hi,

> To reproduce:
>
>   (tramp-dissect-file-name "/ssh:[2001::abcd]#2202:/tmp/xxx")
>
> Expected result: the result "port" should be "2202"
>
> Current result: the result "port" is empty

Indeed.

--8<---------------cut here---------------start------------->8---
(tramp-dissect-file-name "/ssh:[2001::abcd]#2202:/tmp/xxx")
=> (tramp-file-name "ssh" nil nil "2001::abcd#2202" nil "/tmp/xxx" nil)
--8<---------------cut here---------------end--------------->8---

That is a structure, which has "2001::abcd#2202" as host name. Ouch.

Will see how I could fix it.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-06 17:00 UTC (permalink / raw
  To: Yikai Zhao; +Cc: 71972

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

Michael Albinus <michael.albinus@gmx.de> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 573 bytes --]

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.")

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Yikai Zhao @ 2024-07-07  6:31 UTC (permalink / raw
  To: Michael Albinus; +Cc: 71972

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.

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?

On Sun, Jul 7, 2024 at 1:00 AM Michael Albinus <michael.albinus@gmx.de> wrote:
>
> Michael Albinus <michael.albinus@gmx.de> 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.
>





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly
  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
  2024-07-07 15:56         ` Yikai Zhao
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-07 10:28 UTC (permalink / raw
  To: Yikai Zhao; +Cc: 71972

[-- 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 "|"

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly
  2024-07-07 10:28       ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 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
  0 siblings, 1 reply; 7+ messages in thread
From: Yikai Zhao @ 2024-07-07 15:56 UTC (permalink / raw
  To: Michael Albinus; +Cc: 71972

Thanks! I can confirm this patch fixes the issue for me.

BTW, is there any chance that this patch would make it into emacs 30 release?


Regards, Yikai

On Sun, Jul 7, 2024 at 6:28 PM Michael Albinus <michael.albinus@gmx.de> wrote:
>
> 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.
>





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#71972: 31.0.50; Tramp does not parse ipv6 address with port correctly
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-07 17:47 UTC (permalink / raw
  To: Yikai Zhao; +Cc: 71972-done

Version: 30.1

Yikai Zhao <yikai@z1k.dev> writes:

Hi Yikai,

> Thanks! I can confirm this patch fixes the issue for me.

Thanks for the feedback.

> BTW, is there any chance that this patch would make it into emacs 30 release?

Yep. I've pushed the patch to the emacs-30 branch, closing this bug.

> Regards, Yikai

Best regards, Michael.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-07-07 17:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.