Browse code

Make is_ipv4_address a bit more robust

Still not ideal, but at least should avoid matching IPv6 addresses.

Change-Id: Ibb64263fdb0308f56c18518289501dd4642dcbad

Jens Harbott authored on 2017/09/20 02:43:48
Showing 1 changed files
... ...
@@ -2014,7 +2014,7 @@ function cidr2netmask {
2014 2014
 # Check if this is a valid ipv4 address string
2015 2015
 function is_ipv4_address {
2016 2016
     local address=$1
2017
-    local regex='([0-9]{1,3}.){3}[0-9]{1,3}'
2017
+    local regex='([0-9]{1,3}\.){3}[0-9]{1,3}'
2018 2018
     # TODO(clarkb) make this more robust
2019 2019
     if [[ "$address" =~ $regex ]] ; then
2020 2020
         return 0