whitequark / ipaddr.js

IP address manipulation library in JavaScript
MIT License
570 stars 92 forks source link

IP address '1.1' considered valid in the version 2.1.0 #179

Closed pinggi closed 3 months ago

pinggi commented 3 months ago

The version 2.1.0 now considers ip address 1.1 as valid. Is this intentional and actually correct?

ipaddr.js 1.9.1

IpAddr.isValid('1.1')) => false
IpAddr.parse('1.1')) => Error: ipaddr: the address has neither IPv6 nor IPv4 format

ipaddr.js 2.1.0

IpAddr.isValid('1.1')) => true
IpAddr.parse('1.1')) => IPv4 { octets: [ 1, 0, 0, 1 ] }
whitequark commented 3 months ago

Yeah. So does ping:

$ ping 1.1
PING 1.1 (1.0.0.1) 56(84) bytes of data.
64 bytes from 1.0.0.1: icmp_seq=1 ttl=57 time=15.1 ms
^C
--- 1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 15.088/15.088/15.088/0.000 ms