From 8f83fea89092e943297c5aa88078158e0eea602a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2016 13:26:00 +0100 Subject: [PATCH] escaped "." in regex for ipv4 Validation --- src/Ip.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Ip.php b/src/Ip.php index a7bbc14a0..0f732caf2 100644 --- a/src/Ip.php +++ b/src/Ip.php @@ -97,15 +97,15 @@ public function isValid($value) */ protected function validateIPv4($value) { - if (preg_match('/^([01]{8}.){3}[01]{8}\z/i', $value)) { + if (preg_match('/^([01]{8}\.){3}[01]{8}\z/i', $value)) { // binary format 00000000.00000000.00000000.00000000 $value = bindec(substr($value, 0, 8)) . '.' . bindec(substr($value, 9, 8)) . '.' . bindec(substr($value, 18, 8)) . '.' . bindec(substr($value, 27, 8)); - } elseif (preg_match('/^([0-9]{3}.){3}[0-9]{3}\z/i', $value)) { + } elseif (preg_match('/^([0-9]{3}\.){3}[0-9]{3}\z/i', $value)) { // octet format 777.777.777.777 $value = (int) substr($value, 0, 3) . '.' . (int) substr($value, 4, 3) . '.' . (int) substr($value, 8, 3) . '.' . (int) substr($value, 12, 3); - } elseif (preg_match('/^([0-9a-f]{2}.){3}[0-9a-f]{2}\z/i', $value)) { + } elseif (preg_match('/^([0-9a-f]{2}\.){3}[0-9a-f]{2}\z/i', $value)) { // hex format ff.ff.ff.ff $value = hexdec(substr($value, 0, 2)) . '.' . hexdec(substr($value, 3, 2)) . '.' . hexdec(substr($value, 6, 2)) . '.' . hexdec(substr($value, 9, 2));