Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

foo

  • Loading branch information...
commit 413e8c0ee626cb572bec05021f5d2e6fffd39cb7 1 parent 4aa4d48
@djzort authored
Showing with 9 additions and 4 deletions.
  1. +1 −0  Changes
  2. +6 −0 lib/NetAddr/MAC.pm
  3. +2 −4 t/150-misc-bad-formats.t
View
1  Changes
@@ -2,6 +2,7 @@ NetAddr::MAC - A MAC address object
0.82 2013-12-09
- Tests for bad mac addresses from Oliver Gorwits (http://gorwits.me.uk/)
+ - For Cisco format 1111.2222.3333 - we no longer support dropping leading zeros. This was a trade off to better detect broken mac's. Cisco doesnt drop them anyway so its, IMO, the most sensible compromise.
0.81 2013-11-01
- Handle strange things like aabb.cc.11.22.33 or 11.22.33.aabbcc
View
6 lib/NetAddr/MAC.pm
@@ -314,6 +314,12 @@ sub new {
# 0019:e301:0e72
if ( @parts == EUI48LENGTHDEC / 2 || @parts == EUI64LENGTHDEC / 2 )
{
+ # it would be nice to accept no leading 0's but this gives
+ # problems detecting broken formatted macs.
+ # cisco doesnt drop leading zeros so lets go for the least
+ # edgey of the edge cases.
+ last if (first {length $_ < 4} @parts);
+
return [
map {
m{^ ([a-f0-9]{2}) ([a-f0-9]{2}) $}ix
View
6 t/150-misc-bad-formats.t
@@ -2,7 +2,7 @@
use strict;
use warnings FATAL => 'all';
-use Test::More 0.88;
+use Test::More tests => 6;
BEGIN {
use_ok('NetAddr::MAC');
@@ -25,8 +25,6 @@ eval{NetAddr::MAC->new('1:1')};
like ($@,
qr/Invalid MAC format/, 'Bad MAC octet');
-eval{NetAddr::MAC->new('11:22:33:44')};
+eval{NetAddr::MAC->new('11:22:33')};
like ($@,
qr/Invalid MAC format/, 'Short MAC');
-
-done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.