From 451d8fe359cbacaa16fbb24bf6137d71f5d4365d Mon Sep 17 00:00:00 2001 From: Yoni Jah Date: Tue, 9 Feb 2016 09:48:21 +0800 Subject: [PATCH] fixed wrongly approved zero padded ip 4 --- test/validators.js | 4 ++++ validator.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/validators.js b/test/validators.js index 465edc013..dd3920421 100644 --- a/test/validators.js +++ b/test/validators.js @@ -443,6 +443,10 @@ describe('Validators', function () { , '256.0.0.0' , '0.0.0.256' , '26.0.0.256' + , '0200.200.200.200' + , '200.0200.200.200' + , '200.200.0200.200' + , '200.200.200.0200' , '::banana' , 'banana::' , '::1banana' diff --git a/validator.js b/validator.js index c48fa9e2a..c3c46fd2e 100644 --- a/validator.js +++ b/validator.js @@ -54,7 +54,7 @@ var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/; - var ipv4Maybe = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ + var ipv4Maybe = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ , ipv6Block = /^[0-9A-F]{1,4}$/i; var uuid = {