commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Kusnierz (JIRA)" <>
Subject [jira] [Commented] (VALIDATOR-421) InetAddressValidator IPV4 rejects IPs with leading 0's in octets
Date Thu, 06 Apr 2017 14:41:41 GMT


Matt Kusnierz commented on VALIDATOR-421:

ok, maybe not strictly a bug; but ambiguous != invalid. Are there any systems that reject
an IPv4 address with leading 0's? If not, although some systems might interpret the leading
0's differently that doesn't make an IP address with leading 0's invalid... I'm not saying
it is a good idea; and it isn't ambiguous; but it is not strictly invalid. This class also
broken behavioural backwards compatibility, because this leading 0's check was not there in
earlier versions (e.g. 1.4.0) causing an upgrade to generate late run-time/validation errors
that could easily slip through testing and only get reproduced in production.
I would suggest an enhancement that exposes an overloaded isValidInet4Address(string inet4Address,
Ipv4Strictness strictness) method
enum Ipv4Strictness {
DECIMAL_STRICT, //enforced leading zeros
DECIMAL_RELAXED, //allows leading zeros

I would suggest that the default should in fact get reverted to the relaxed strictness mode;
especially if oracle java 8 accepts IPs in this format.

> InetAddressValidator IPV4 rejects IPs with leading 0's in octets
> ----------------------------------------------------------------
>                 Key: VALIDATOR-421
>                 URL:
>             Project: Commons Validator
>          Issue Type: Bug
>          Components: Routines
>    Affects Versions: 1.6
>            Reporter: Matt Kusnierz
> According to Wikipedia "It [IPv4] also allowed the numbers to be written in hexadecimal
and octal, by prefixing them with 0x and 0, respectively", but org.apache.commons.validator.routines.InetAddressValidator.isValidInet4Address(String)
rejects IPs if an ipSegment starts with a leading 0.
> So leading 0's should be detected first, and then used to try and parseInt using the
octal radix.
> The ipv4 regex also doesn't support hex notation.

This message was sent by Atlassian JIRA

View raw message