Closed Ellingson closed 4 years ago
@Ellingson Thank you for your proposal!
However, this is almost correct behavior and is compliant to the de-facto standard.
Please read section 7.4, RFC3986.
some implementations allow each dotted part to be interpreted as decimal, octal, or hexadecimal, as specified in the C language (i.e., a leading 0x or 0X implies hexadecimal; a leading 0 implies octal; otherwise, the number is interpreted as decimal).
This behavior is the same with not only .NET runtime but also many many OS and network tools, such as the "ping" command on a Linux OS.
This is not a strict rule, but many platforms and tools compliant this behavior, so I have no plan to fix this library at this point.
Thank you for your understanding! 😄
var testIp = IPAddressRange.Parse("192.168.009.215");
This fails with a "System.FormatException: 'An invalid IP address was specified.'" error.
Seems the issue is with IPAddress.Parse() in .NET treating leading zeros as Octal identifiers.
At least for IPv4, you can use the following to clean prior to parsing...
ipString = Regex.Replace(ipString, "0*([0-9]+)", "${1}");