Fixed IPv6 validation special case: single colon

IPv6 parsing was incorrectly evaluating ':' as a valid IPv6 address.

https://fedorahosted.org/freeipa/ticket/1466
This commit is contained in:
Petr Vobornik 2012-01-03 09:37:17 +01:00 committed by Endi S. Dewata
parent c7ae0c20db
commit ceee08faa1
2 changed files with 8 additions and 0 deletions

View File

@ -125,6 +125,11 @@ NET.ip_address = function(spec) {
var i;
//usecases like ':'
if (that.parts.length <= 2) {
return that.set_error('invalid format');
}
for (i=0; i<that.parts.length; i++) {
var part = that.parts[i];

View File

@ -156,6 +156,9 @@ test('Testing incorrect IPv6 addresses', function() {
address = NET.ip_address('2001:db8:85a3:0:0:8a2e:370');
ok(!address.valid, 'Missing part - 2001:db8:85a3:0:0:8a2e:370');
address = NET.ip_address(':');
ok(!address.valid, 'Address - :');
address = NET.ip_address('::1::');
ok(!address.valid, 'Address - ::1::');