-
-
Notifications
You must be signed in to change notification settings - Fork 548
IPv4 validation regex validates faulty ip adresses #1409
Copy link
Copy link
Closed
Description
Hi,
the class IpV4FormatValidator contains a regex:
private const string IpV4RegexExpression = "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
This one supports also an ip address with only three parts, like: 192.168.178
A correct one would be: ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
I got this one from regular-expressions-cookbook@oreilly. Basically these are the same, but the implementation is missing the
"?:(?:" at the start and "\" in the middle.
Reactions are currently unavailable