GH-340: Improve IPv4/IPv6 regexes, extraction, and validity functions

* is_valid_ip() is now implemented as a BIF instead of in
  base/utils/addrs

* The IPv4 and IPv6 regular expressions provided by base/utils/addrs
  have been improved/corrected (previously they could possibly match
  some invalid IPv4 decimals, or various "zero compressed" IPv6 strings
  with too many hextets)

* extract_ip_addresses() should give better results as a result of
  the above two points
This commit is contained in:
Jon Siwek 2019-04-18 19:04:39 -07:00
parent 9421ee0293
commit 7144661930
8 changed files with 200 additions and 106 deletions

View file

@ -1,4 +1,4 @@
============ test ipv4 regex
============ test ipv4 regex (good strings)
T
T
T
@ -6,9 +6,24 @@ T
T
T
T
T
T
T
T
T
T
T
============ bad ipv4 decimals
F
F
F
F
F
F
============ too many ipv4 decimals
F
F
============ typical looking ipv4
T
T
============ test ipv6 regex
@ -30,6 +45,9 @@ T
F
F
F
F
F
============ test extract_ip_addresses()
[1.1.1.1, 2.2.2.2, 3.3.3.3]
[1.1.1.1, 0:0:0:0:0:0:0:0, 3.3.3.3]
[6:1:2::3:4:5:6]