Closed Taiki-San closed 4 years ago
Digging a bit, it looks like this is actually a classful variants of the IP that the parser explicitly ignore. Would you be open to a PR adding support?
Yup, sure. Looks like I missed some--I thought I got them all, but it was a long time ago.
You explicitly mentioned those in a comment (https://github.com/whitequark/ipaddr.js/blob/master/lib/ipaddr.js#L316-L319) so I wasn't sure if not supporting them was a deliberate design decision. Thanks for the precision, working the on the PR right now :)
It was sort of deliberate. I included all the bizarre formats (like a single hex field) for compatibility with inet_aton
. I didn't include the classful ones because, IIRC, I didn't feel like implementing them. Since inet_aton
does accept those, and I don't have to do the work, there's no reason to not accept a PR.
Hi!
We discovered that compressed IPv4 (
127.1
instead of127.0.0.1
) are accepted by http libraries despite raisingipaddr: the address has neither IPv6 nor IPv4 format
when callingipaddr.parse
on it.Because I couldn't find mentions of such a format in the formatting spec for IPv4 I could find, I don't know if that's a case you want to support in the library.
Otherwise, I could add a first stage in my code before
ipaddr
to try to detect and complete them.