unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* PROPOSAL: New function ffap-ip-at-point
@ 2022-07-22  8:49 Iñigo Serna
  2022-07-22  9:36 ` Robert Pluim
  2022-07-22 11:20 ` Eli Zaretskii
  0 siblings, 2 replies; 19+ messages in thread
From: Iñigo Serna @ 2022-07-22  8:49 UTC (permalink / raw)
  To: emacs-devel

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

Hi,

I propose the addition of this `ffap-ip-at-point' function.
Equivalent to (and based on) `ffap-machine-at-point', it will 
return
the IP address at point if it exists, or nil.

The attached patch also includes a very minor change to
`dns-lookup-host' command in order to use it if 
ffap-machine-at-point
first fails.

Patch is against master from a couple of hours ago.
This is my first serious contribution to emacs, so I'm not sure 
it's everything ok.
What do you think? 

Btw, I signed FSF papers in 2021, so no problem here I guess.

Thanks,
-- 
Iñigo Serna

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ffap-ip-at-point__dns-host-lookup.diff --]
[-- Type: text/x-patch, Size: 1929 bytes --]

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 9de0dd40d1..a0751fbd8e 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -641,6 +641,25 @@ ffap-fixup-url
    ((and ffap-url-unwrap-remote (ffap-url-unwrap-remote url)))
    (url)))

+\f
+;;; IP Address (`ffap-ip-p'):
+
+;;;###autoload
+(defun ffap-ip-at-point ()
+  "Return IP address at point if it exists, or nil."
+  (let ((mach (ffap-string-at-point 'ip)))
+    (and (ffap-ip-p mach) mach)))
+
+(defun ffap-ip-p (ip)
+  "Decide whether IP is a valid IP address."
+  (when-let* ((start (string-match "\\([0-9]\\{1,3\\}\\.\\)\\{3\\}[0-9]\\{1,3\\}" ip))
+              (end (match-end 0))
+              (nums (mapcar #'string-to-number (split-string (substring ip start end) "\\."))))
+    (message "|%S|%S|%S|" start end (length ip))
+    (and (zerop start)
+         (length= ip end)
+         (seq-every-p #'(lambda (num) (and (>= num 0) (<= num 255))) nums))))
+
 \f
 ;;; File Name Handling:
 ;;
@@ -1094,6 +1113,8 @@ ffap-string-at-point-mode-alist
     (nocolon "--9$+<>@-Z_[:alpha:]~" "<@" "@>;.,!?")
     ;; A machine:
     (machine "-[:alnum:]." "" ".")
+    ;; An IP address:
+    (ip "[0-9]." "" ".")
     ;; Mathematica paths: allow backquotes
     (math-mode ",-:$+<>@-Z_[:lower:]~`" "<" "@>;.,!?`:")
     ;; (La)TeX: don't allow braces
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index c7ff175e08..4bcfcb122d 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -577,7 +577,7 @@ dns-lookup-host

 This command uses `dns-lookup-program' for looking up the DNS information."
   (interactive
-   (list (let ((default (ffap-machine-at-point)))
+   (list (let ((default (or (ffap-machine-at-point) (ffap-ip-at-point))))
            (read-string (format-prompt "Lookup host" default) nil nil default))
          (if current-prefix-arg (read-from-minibuffer "Name server: "))))
   (let ((options

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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22  8:49 PROPOSAL: New function ffap-ip-at-point Iñigo Serna
@ 2022-07-22  9:36 ` Robert Pluim
  2022-07-22 11:20 ` Eli Zaretskii
  1 sibling, 0 replies; 19+ messages in thread
From: Robert Pluim @ 2022-07-22  9:36 UTC (permalink / raw)
  To: Iñigo Serna; +Cc: emacs-devel

>>>>> On Fri, 22 Jul 2022 10:49:30 +0200, Iñigo Serna <inigoserna@gmx.com> said:

    Iñigo> Hi,
    Iñigo> I propose the addition of this `ffap-ip-at-point' function.
    Iñigo> Equivalent to (and based on) `ffap-machine-at-point', it will return
    Iñigo> the IP address at point if it exists, or nil.

IPv6?

    Iñigo> The attached patch also includes a very minor change to
    Iñigo> `dns-lookup-host' command in order to use it if ffap-machine-at-point
    Iñigo> first fails.

    Iñigo> Patch is against master from a couple of hours ago.
    Iñigo> This is my first serious contribution to emacs, so I'm not sure it's
    Iñigo> everything ok.
    Iñigo> What do you think? Btw, I signed FSF papers in 2021, so no problem
    Iñigo> here I guess.

Youʼll need a ChangeLog style commit message. See CONTRIBUTE for
details (specifically "Generating ChangeLog entries"), but an easy way
to start is "C-x 4 a" in the buffer resulting from "C-x v ="

Robert
-- 



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22  8:49 PROPOSAL: New function ffap-ip-at-point Iñigo Serna
  2022-07-22  9:36 ` Robert Pluim
@ 2022-07-22 11:20 ` Eli Zaretskii
  2022-07-22 14:46   ` Iñigo Serna
  1 sibling, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2022-07-22 11:20 UTC (permalink / raw)
  To: Iñigo Serna; +Cc: emacs-devel

> From: Iñigo Serna <inigoserna@gmx.com>
> Date: Fri, 22 Jul 2022 10:49:30 +0200
> 
> I propose the addition of this `ffap-ip-at-point' function.
> Equivalent to (and based on) `ffap-machine-at-point', it will 
> return
> the IP address at point if it exists, or nil.

IPv4 or IPv6 addresses? or both?  This should be stated in the doc
string.

This also needs a NEWS entry.

> +(defun ffap-ip-at-point ()
> +  "Return IP address at point if it exists, or nil."

"If it exists" is ambiguous for an IP address, so please try coming up
with a better wording.

> +(defun ffap-ip-p (ip)
> +  "Decide whether IP is a valid IP address."
> +  (when-let* ((start (string-match "\\([0-9]\\{1,3\\}\\.\\)\\{3\\}[0-9]\\{1,3\\}" ip))
> +              (end (match-end 0))
> +              (nums (mapcar #'string-to-number (split-string (substring ip start end) "\\."))))
> +    (message "|%S|%S|%S|" start end (length ip))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Leftover from debugging?

Finally, can you add a couple of tests for this facility?

Thanks.



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 11:20 ` Eli Zaretskii
@ 2022-07-22 14:46   ` Iñigo Serna
  2022-07-22 15:01     ` Eli Zaretskii
                       ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Iñigo Serna @ 2022-07-22 14:46 UTC (permalink / raw)
  To: emacs-devel; +Cc: Eli Zaretskii, Robert Pluim

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

Thanks Robert and Eli for your comments and suggestions.


On 22 July 2022 at 11:36 +02, Robert Pluim <rpluim@gmail.com> 
wrote:

> IPv6?

Parsing IPv6 addresses is much more complex: can be shortened and 
even
one or more leading zeros from any group of hexadecimal digits 
could be
removed. Too much work for this humble patch.

> Youʼll need a ChangeLog style commit message. 

What about this?

##################################################
Fri Jul 22 16:37:25 2022  Iñigo Serna  <inigoserna@gmx.com>

Add functions ffap-ipv4-at-point, ffap-ipv4-p

	* lisp/ffap.el (ffap-ipv4-at-point): New functions.
	* lisp/ffap.el (ffap-ipv4-p): 
	* lisp/ffap.el (ffap-string-at-point-mode-alist): Add ipv4 
      mode.
	* test/lisp/ffap-tests.el (ffap-ipv4-at-point): Add tests.
	* etc/NEWS: Document new functions.
	* lisp/net/net-utils.el (dns-lookup-host): try to use
	ffap-ipv4-at-point if hostname is not found first.
##################################################

Anyway, I don't have commit rights so some other one should 
perform the
commit and add the message.


On 22 July 2022 at 13:20 +02, Eli Zaretskii <eliz@gnu.org> wrote:

> IPv4 or IPv6 addresses? or both?  This should be stated in the 
> doc
> string.

It's only for IPv4 addresses. I'll add this information to the doc 
string.
I renamed the functions to 'ffap-ipv4-at-point' and 'ffap-ipv4-p'.

> This also needs a NEWS entry.

Added. Please check it, as my English is not good.

>> +(defun ffap-ip-at-point ()
>> +  "Return IP address at point if it exists, or nil."
>
> "If it exists" is ambiguous for an IP address, so please try 
> coming up
> with a better wording.

Sorry. What about "if it is found at point"?

> [...]
> Leftover from debugging?

Glub! Removed, sorry.

> Finally, can you add a couple of tests for this facility?

Added.


I've attached a new version of the patch. Hope you like it better.

Thanks,
--
Iñigo Serna

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ffap-ip-at-point__dns-host-lookup-v2.diff --]
[-- Type: text/x-patch, Size: 3464 bytes --]

diff --git a/etc/NEWS b/etc/NEWS
index a143550f03..67a2f9833d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -335,6 +335,11 @@ Use something like 'M-x shell RET ssh <host> RET' instead.
 \f
 * Changes in Emacs 29.1

+---
+** New functions 'ffap-ipv4-at-point', 'ffap-ipv4-p'
+'ffap-ipv4-at-point' return an IPv4 address if it is found at point,
+or nil.  'ffap-ipv4-p' check for a valid IPv4 address.
+
 ---
 ** Emacs is now capable of editing files with arbitrarily long lines.
 The display of long lines has been optimized, and Emacs no longer
diff --git a/lisp/ffap.el b/lisp/ffap.el
index 9de0dd40d1..44e9ed9b1e 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -641,6 +641,24 @@ ffap-fixup-url
    ((and ffap-url-unwrap-remote (ffap-url-unwrap-remote url)))
    (url)))

+\f
+;;; IP Address (`ffap-ipv4-p'):
+
+;;;###autoload
+(defun ffap-ipv4-at-point ()
+  "Return an IPv4 address if it is found at point, or nil."
+  (let ((mach (ffap-string-at-point 'ipv4)))
+    (and (ffap-ipv4-p mach) mach)))
+
+(defun ffap-ipv4-p (ip)
+  "Decide whether IP is a valid IPv4 address."
+  (when-let* ((start (string-match "\\([0-9]\\{1,3\\}\\.\\)\\{3\\}[0-9]\\{1,3\\}" ip))
+              (end (match-end 0))
+              (nums (mapcar #'string-to-number (split-string (substring ip start end) "\\."))))
+    (and (zerop start)
+         (length= ip end)
+         (seq-every-p #'(lambda (num) (and (>= num 0) (<= num 255))) nums))))
+
 \f
 ;;; File Name Handling:
 ;;
@@ -1094,6 +1112,8 @@ ffap-string-at-point-mode-alist
     (nocolon "--9$+<>@-Z_[:alpha:]~" "<@" "@>;.,!?")
     ;; A machine:
     (machine "-[:alnum:]." "" ".")
+    ;; An IPv4 address:
+    (ipv4 "[0-9]." "" ".")
     ;; Mathematica paths: allow backquotes
     (math-mode ",-:$+<>@-Z_[:lower:]~`" "<" "@>;.,!?`:")
     ;; (La)TeX: don't allow braces
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index c7ff175e08..15195a1fdf 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -577,7 +577,7 @@ dns-lookup-host

 This command uses `dns-lookup-program' for looking up the DNS information."
   (interactive
-   (list (let ((default (ffap-machine-at-point)))
+   (list (let ((default (or (ffap-machine-at-point) (ffap-ipv4-at-point))))
            (read-string (format-prompt "Lookup host" default) nil nil default))
          (if current-prefix-arg (read-from-minibuffer "Name server: "))))
   (let ((options
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 4b580b5af5..1f9313e274 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -158,6 +158,32 @@ ffap-test-path
     (goto-char (point-min))
     (should (equal (ffap-file-at-point) nil))))

+(ert-deftest ffap-ipv4-at-point ()
+  (with-temp-buffer
+    (insert "\
+aaaaaaaaaaaaaaaaaaaaaaa
+3.14,15:92
+1.X2.3.4
+5.6.7
+8.9.444.2
+1.2.3.4
+bbbb5.6.7.8ccc\n")
+    (goto-char (point-min))
+    (should-not (ffap-ipv4-at-point))
+    (forward-line)
+    (should-not (ffap-ipv4-at-point))
+    (forward-line)
+    (should-not (ffap-ipv4-at-point))
+    (forward-line)
+    (should-not (ffap-ipv4-at-point))
+    (forward-line)
+    (should-not (ffap-ipv4-at-point))
+    (forward-line)
+    (should (equal (ffap-ipv4-at-point) "1.2.3.4"))
+    (forward-line)
+    (forward-char 7)
+    (should (equal (ffap-ipv4-at-point) "5.6.7.8"))))
+
 (provide 'ffap-tests)

 ;;; ffap-tests.el ends here

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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 14:46   ` Iñigo Serna
@ 2022-07-22 15:01     ` Eli Zaretskii
  2022-07-22 15:04     ` Brian Cully via Emacs development discussions.
  2022-07-22 15:09     ` Lars Ingebrigtsen
  2 siblings, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2022-07-22 15:01 UTC (permalink / raw)
  To: Iñigo Serna; +Cc: emacs-devel, rpluim

> From: Iñigo Serna <inigoserna@gmx.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, Robert Pluim <rpluim@gmail.com>
> Date: Fri, 22 Jul 2022 16:46:44 +0200
> 
> Thanks Robert and Eli for your comments and suggestions.

And thank you for working on this in the first place.

> +---
> +** New functions 'ffap-ipv4-at-point', 'ffap-ipv4-p'
> +'ffap-ipv4-at-point' return an IPv4 address if it is found at point,
                        ^^^^^^
"returns"

> +or nil.  'ffap-ipv4-p' check for a valid IPv4 address.
                          ^^^^^
"checks"

Other than that, LGTM.



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 14:46   ` Iñigo Serna
  2022-07-22 15:01     ` Eli Zaretskii
@ 2022-07-22 15:04     ` Brian Cully via Emacs development discussions.
  2022-07-22 15:28       ` Iñigo Serna
  2022-07-22 15:09     ` Lars Ingebrigtsen
  2 siblings, 1 reply; 19+ messages in thread
From: Brian Cully via Emacs development discussions. @ 2022-07-22 15:04 UTC (permalink / raw)
  To: Iñigo Serna; +Cc: Eli Zaretskii, Robert Pluim, emacs-devel


Iñigo Serna <inigoserna@gmx.com> writes:

> Parsing IPv6 addresses is much more complex: can be shortened 
> and even
> one or more leading zeros from any group of hexadecimal digits 
> could
> be
> removed. Too much work for this humble patch.

This is also true for IPv4: any string of zeroes may be elided, 
just like IPv6.

--8<---------------cut here---------------start------------->8---
ditto:~% ping 127.1
PING 127.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.033 ms
--8<---------------cut here---------------end--------------->8---

-bjc



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 14:46   ` Iñigo Serna
  2022-07-22 15:01     ` Eli Zaretskii
  2022-07-22 15:04     ` Brian Cully via Emacs development discussions.
@ 2022-07-22 15:09     ` Lars Ingebrigtsen
  2022-07-22 15:34       ` Iñigo Serna
  2 siblings, 1 reply; 19+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-22 15:09 UTC (permalink / raw)
  To: Iñigo Serna; +Cc: emacs-devel, Eli Zaretskii, Robert Pluim

Iñigo Serna <inigoserna@gmx.com> writes:

> Parsing IPv6 addresses is much more complex: can be shortened and even
> one or more leading zeros from any group of hexadecimal digits could
> be
> removed. Too much work for this humble patch.

Have a look at textsec--ipvx-address-p -- I think that should do the
right thing?  (And could be moved somewhere more central if it's doing
the right thing here for reuse.)

I think for this to be useful, it should cover both ipv4 and ipv6.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 15:04     ` Brian Cully via Emacs development discussions.
@ 2022-07-22 15:28       ` Iñigo Serna
  0 siblings, 0 replies; 19+ messages in thread
From: Iñigo Serna @ 2022-07-22 15:28 UTC (permalink / raw)
  To: Brian Cully; +Cc: Eli Zaretskii, Robert Pluim, emacs-devel


On 22 July 2022 at 17:04 +02, Brian Cully <bjc@spork.org> wrote:

> This is also true for IPv4: any string of zeroes may be elided, 
> just like IPv6.

Of course, but it isn't as common as with IPv6.
You don't usually find any reporting tool with abbreviated IPV4 
addresses.
-- 
Iñigo Serna



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 15:09     ` Lars Ingebrigtsen
@ 2022-07-22 15:34       ` Iñigo Serna
  2022-07-22 15:55         ` Robert Pluim
  2022-07-22 20:10         ` Lars Ingebrigtsen
  0 siblings, 2 replies; 19+ messages in thread
From: Iñigo Serna @ 2022-07-22 15:34 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel, Eli Zaretskii, Robert Pluim

Hi Lars,

On 22 July 2022 at 17:09 +02, Lars Ingebrigtsen <larsi@gnus.org> 
wrote:

> Have a look at textsec--ipvx-address-p -- I think that should do 
> the
> right thing?  (And could be moved somewhere more central if it's 
> doing
> the right thing here for reuse.)

'textsec--ipvx-address-p' current implementation is not perfect.
It returns a wrong result when some octet is greater than 255.

(textsec--ipvx-address-p "343.1.2.3")
0

(ffap-ipv4-p "343.1.2.3")
nil

So IMO it's not as useful for my purposes, reports from network 
tools.


> I think for this to be useful, it should cover both ipv4 and 
> ipv6.

IPv6 could be added later.

-- 
Iñigo Serna



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 15:34       ` Iñigo Serna
@ 2022-07-22 15:55         ` Robert Pluim
  2022-07-22 20:10         ` Lars Ingebrigtsen
  1 sibling, 0 replies; 19+ messages in thread
From: Robert Pluim @ 2022-07-22 15:55 UTC (permalink / raw)
  To: Iñigo Serna; +Cc: Lars Ingebrigtsen, emacs-devel, Eli Zaretskii

>>>>> On Fri, 22 Jul 2022 17:34:06 +0200, Iñigo Serna <inigoserna@gmx.com> said:

    Iñigo> Hi Lars,
    Iñigo> On 22 July 2022 at 17:09 +02, Lars Ingebrigtsen <larsi@gnus.org>
    Iñigo> wrote:

    >> Have a look at textsec--ipvx-address-p -- I think that should do the
    >> right thing?  (And could be moved somewhere more central if it's
    >> doing
    >> the right thing here for reuse.)

    Iñigo> 'textsec--ipvx-address-p' current implementation is not perfect.
    Iñigo> It returns a wrong result when some octet is greater than 255.

    Iñigo> (textsec--ipvx-address-p "343.1.2.3")
    Iñigo> 0

    Iñigo> (ffap-ipv4-p "343.1.2.3")
    Iñigo> nil

    Iñigo> So IMO it's not as useful for my purposes, reports from network tools.

We could extend network-lookup-address-info so that it could pass
AI_NUMERICHOST to getaddrinfo, which would then check that itʼs
been passed a valid numeric IP address.

Robert
-- 



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 15:34       ` Iñigo Serna
  2022-07-22 15:55         ` Robert Pluim
@ 2022-07-22 20:10         ` Lars Ingebrigtsen
  2022-07-23  7:31           ` Robert Pluim
  1 sibling, 1 reply; 19+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-22 20:10 UTC (permalink / raw)
  To: Iñigo Serna; +Cc: emacs-devel, Eli Zaretskii, Robert Pluim

Iñigo Serna <inigoserna@gmx.com> writes:

> 'textsec--ipvx-address-p' current implementation is not perfect.
> It returns a wrong result when some octet is greater than 255.
>
> (textsec--ipvx-address-p "343.1.2.3")
> 0
>
> (ffap-ipv4-p "343.1.2.3")
> nil
>
> So IMO it's not as useful for my purposes, reports from network tools.

Well, we could trivially fix that in that function.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-22 20:10         ` Lars Ingebrigtsen
@ 2022-07-23  7:31           ` Robert Pluim
  2022-07-23  7:37             ` Lars Ingebrigtsen
  2022-07-23  7:39             ` Andreas Schwab
  0 siblings, 2 replies; 19+ messages in thread
From: Robert Pluim @ 2022-07-23  7:31 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Iñigo Serna, emacs-devel, Eli Zaretskii

>>>>> On Fri, 22 Jul 2022 22:10:41 +0200, Lars Ingebrigtsen <larsi@gnus.org> said:

    Lars> Iñigo Serna <inigoserna@gmx.com> writes:
    >> 'textsec--ipvx-address-p' current implementation is not perfect.
    >> It returns a wrong result when some octet is greater than 255.
    >> 
    >> (textsec--ipvx-address-p "343.1.2.3")
    >> 0
    >> 
    >> (ffap-ipv4-p "343.1.2.3")
    >> nil
    >> 
    >> So IMO it's not as useful for my purposes, reports from network tools.

    Lars> Well, we could trivially fix that in that function.

How far down the rabbit hole do we want to go, knowing that libc has
already done this? Note: "0343.1.2.3" is a valid representation of an
IPv4 address, as is "0", or "1".

Robert
-- 



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-23  7:31           ` Robert Pluim
@ 2022-07-23  7:37             ` Lars Ingebrigtsen
  2022-07-23  7:46               ` Robert Pluim
  2022-07-23  7:39             ` Andreas Schwab
  1 sibling, 1 reply; 19+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  7:37 UTC (permalink / raw)
  To: Robert Pluim; +Cc: Iñigo Serna, emacs-devel, Eli Zaretskii

Robert Pluim <rpluim@gmail.com> writes:

> How far down the rabbit hole do we want to go, knowing that libc has
> already done this?

Doesn't calling the resolver result in network traffic?  That would be
unexpected from ffap (and a loss of privacy).

> Note: "0343.1.2.3" is a valid representation of an
> IPv4 address, as is "0", or "1".

Perhaps it'd be nice to write a complete IP address parser?




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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-23  7:31           ` Robert Pluim
  2022-07-23  7:37             ` Lars Ingebrigtsen
@ 2022-07-23  7:39             ` Andreas Schwab
  1 sibling, 0 replies; 19+ messages in thread
From: Andreas Schwab @ 2022-07-23  7:39 UTC (permalink / raw)
  To: Robert Pluim
  Cc: Lars Ingebrigtsen, Iñigo Serna, emacs-devel, Eli Zaretskii

On Jul 23 2022, Robert Pluim wrote:

> How far down the rabbit hole do we want to go, knowing that libc has
> already done this? Note: "0343.1.2.3" is a valid representation of an
> IPv4 address, as is "0", or "1".

Or "0xe3010203".

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-23  7:37             ` Lars Ingebrigtsen
@ 2022-07-23  7:46               ` Robert Pluim
  2022-07-23  7:47                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 19+ messages in thread
From: Robert Pluim @ 2022-07-23  7:46 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Iñigo Serna, emacs-devel, Eli Zaretskii

>>>>> On Sat, 23 Jul 2022 09:37:10 +0200, Lars Ingebrigtsen <larsi@gnus.org> said:

    Lars> Robert Pluim <rpluim@gmail.com> writes:
    >> How far down the rabbit hole do we want to go, knowing that libc has
    >> already done this?

    Lars> Doesn't calling the resolver result in network traffic?  That would be
    Lars> unexpected from ffap (and a loss of privacy).

Not when AI_NUMERICHOST is set

    >> Note: "0343.1.2.3" is a valid representation of an
    >> IPv4 address, as is "0", or "1".

    Lars> Perhaps it'd be nice to write a complete IP address parser?

Iʼm not going to stop anyone :-)

Robert
-- 



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-23  7:46               ` Robert Pluim
@ 2022-07-23  7:47                 ` Lars Ingebrigtsen
  2022-07-26 12:21                   ` Robert Pluim
  0 siblings, 1 reply; 19+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  7:47 UTC (permalink / raw)
  To: Robert Pluim; +Cc: Iñigo Serna, emacs-devel, Eli Zaretskii

Robert Pluim <rpluim@gmail.com> writes:

> Not when AI_NUMERICHOST is set

Oh, OK.  Then I have no objections to punting to libc.




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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-23  7:47                 ` Lars Ingebrigtsen
@ 2022-07-26 12:21                   ` Robert Pluim
  2022-07-26 12:48                     ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Robert Pluim @ 2022-07-26 12:21 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Iñigo Serna, emacs-devel, Eli Zaretskii

>>>>> On Sat, 23 Jul 2022 09:47:48 +0200, Lars Ingebrigtsen <larsi@gnus.org> said:

    Lars> Robert Pluim <rpluim@gmail.com> writes:
    >> Not when AI_NUMERICHOST is set

    Lars> Oh, OK.  Then I have no objections to punting to libc.

Now done on master. Eli, I have no idea how compliant MS-Windowʼs
getaddrinfo is, so itʼs possible that test/src/process-tests.el will
need adjusting, specifically 'lookup-hints-values'.

Robert
-- 



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-26 12:21                   ` Robert Pluim
@ 2022-07-26 12:48                     ` Eli Zaretskii
  2022-07-26 12:54                       ` Robert Pluim
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2022-07-26 12:48 UTC (permalink / raw)
  To: Robert Pluim; +Cc: larsi, inigoserna, emacs-devel

> From: Robert Pluim <rpluim@gmail.com>
> Cc: Iñigo Serna <inigoserna@gmx.com>,  emacs-devel@gnu.org,
>   Eli Zaretskii
>  <eliz@gnu.org>
> Date: Tue, 26 Jul 2022 14:21:16 +0200
> 
> Now done on master. Eli, I have no idea how compliant MS-Windowʼs
> getaddrinfo is, so itʼs possible that test/src/process-tests.el will
> need adjusting, specifically 'lookup-hints-values'.

It seems to pass:

     passed   1/30  lookup-family-specification (0.000000 sec)
     passed   2/30  lookup-google (0.000000 sec)
     passed   3/30  lookup-hints-specification (0.000000 sec)
  localhost/0 No such host is known.
  localhost/0 No such host is known.
  343.1.2.3/0 No such host is known.
  343.1.2.3/0 No such host is known.
  1.2.3.4.5/0 No such host is known.
  1.2.3.4.5/0 No such host is known.
  fe80::1/0 No such host is known.
  e301::203:1/0 No such host is known.
  e301:203::1/0 No such host is known.
  e301:0203::1/0 No such host is known.
  ::1/0 No such host is known.
  ::0/0 No such host is known.
  0343:1:2::3/0 No such host is known.
  343:001:2::3/0 No such host is known.
     passed   4/30  lookup-hints-values (0.015625 sec)
     passed   5/30  lookup-unicode-domains (0.421875 sec)

(This is a system without IPv6.)

But if you want me to try more tests to make sure the above isn't
sheer luck, please tell.



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

* Re: PROPOSAL: New function ffap-ip-at-point
  2022-07-26 12:48                     ` Eli Zaretskii
@ 2022-07-26 12:54                       ` Robert Pluim
  0 siblings, 0 replies; 19+ messages in thread
From: Robert Pluim @ 2022-07-26 12:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, inigoserna, emacs-devel

>>>>> On Tue, 26 Jul 2022 15:48:12 +0300, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Robert Pluim <rpluim@gmail.com>
    >> Cc: Iñigo Serna <inigoserna@gmx.com>,  emacs-devel@gnu.org,
    >> Eli Zaretskii
    >> <eliz@gnu.org>
    >> Date: Tue, 26 Jul 2022 14:21:16 +0200
    >> 
    >> Now done on master. Eli, I have no idea how compliant MS-Windowʼs
    >> getaddrinfo is, so itʼs possible that test/src/process-tests.el will
    >> need adjusting, specifically 'lookup-hints-values'.

    Eli> It seems to pass:

    Eli>      passed   1/30  lookup-family-specification (0.000000 sec)
    Eli>      passed   2/30  lookup-google (0.000000 sec)
    Eli>      passed   3/30  lookup-hints-specification (0.000000 sec)
    Eli>   localhost/0 No such host is known.
    Eli>   localhost/0 No such host is known.
    Eli>   343.1.2.3/0 No such host is known.
    Eli>   343.1.2.3/0 No such host is known.
    Eli>   1.2.3.4.5/0 No such host is known.
    Eli>   1.2.3.4.5/0 No such host is known.
    Eli>   fe80::1/0 No such host is known.
    Eli>   e301::203:1/0 No such host is known.
    Eli>   e301:203::1/0 No such host is known.
    Eli>   e301:0203::1/0 No such host is known.
    Eli>   ::1/0 No such host is known.
    Eli>   ::0/0 No such host is known.
    Eli>   0343:1:2::3/0 No such host is known.
    Eli>   343:001:2::3/0 No such host is known.
    Eli>      passed   4/30  lookup-hints-values (0.015625 sec)
    Eli>      passed   5/30  lookup-unicode-domains (0.421875 sec)

    Eli> (This is a system without IPv6.)

    Eli> But if you want me to try more tests to make sure the above isn't
    Eli> sheer luck, please tell.

No, that output is consistent with what I see for IPv4-only (I did
wonder if I should figure out how to suppress those "No such host is
known" messages, but they can be useful).

Thanks for testing.

Robert
-- 



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

end of thread, other threads:[~2022-07-26 12:54 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-22  8:49 PROPOSAL: New function ffap-ip-at-point Iñigo Serna
2022-07-22  9:36 ` Robert Pluim
2022-07-22 11:20 ` Eli Zaretskii
2022-07-22 14:46   ` Iñigo Serna
2022-07-22 15:01     ` Eli Zaretskii
2022-07-22 15:04     ` Brian Cully via Emacs development discussions.
2022-07-22 15:28       ` Iñigo Serna
2022-07-22 15:09     ` Lars Ingebrigtsen
2022-07-22 15:34       ` Iñigo Serna
2022-07-22 15:55         ` Robert Pluim
2022-07-22 20:10         ` Lars Ingebrigtsen
2022-07-23  7:31           ` Robert Pluim
2022-07-23  7:37             ` Lars Ingebrigtsen
2022-07-23  7:46               ` Robert Pluim
2022-07-23  7:47                 ` Lars Ingebrigtsen
2022-07-26 12:21                   ` Robert Pluim
2022-07-26 12:48                     ` Eli Zaretskii
2022-07-26 12:54                       ` Robert Pluim
2022-07-23  7:39             ` Andreas Schwab

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