Inconsistent octal madness

$ ping 010
PING 010 (0.0.0.8) 56(84) bytes of data.
$ ping 010.1.1.1
PING 010.1.1.1 (8.1.1.1) 56(84) bytes of data.
$ ping 018
ping: 018: Name or service not known
$ ping 18
PING 18 (0.0.0.18) 56(84) bytes of data.
$ ping 018.1.1.1
PING 018.1.1.1 (18.1.1.1) 56(84) bytes of data.
$ ping 18.1.1.1
PING 18.1.1.1 (18.1.1.1) 56(84) bytes of data.

ok sorry, embarrassingly enough it was misdiagnosed by me. It is my silly DNS server that "helpfully" resolves these names for me!
@bagder which DNS server/cache converts names to IP address this way?
@pemensik I did not dig very deep. The closest is my ASUS router's DNS, I didn't check if it is this or next hop that does this craziness. Doesn't matter to me.
@bagder can you send "dig ch txt version.bind" query to it? I expect Dnsmasq of sort. inet_pton() accepts only well specified addresses. inet_aton() accepted almost any random garbage and should be avoided and replaced. Is it possible your ping uses the old call?
@bagder ooh. At least python socket module considers getaddrinfo ('127.1', 0, flags=AI_NUMERICHOST) or even '0x7f.1' as completely valid thing. Expected such legacy crap would get refused, but getaddrinfo does not enforce full IPv4.