Merge pull request #764 from Elfe/master

fix MAC address rule parsing as even/uneven switches at every colon
This commit is contained in:
Adam Ierymenko 2018-06-12 09:37:28 -07:00 committed by GitHub
commit d55c732e19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -226,12 +226,16 @@ function _cleanMac(m)
{ {
m = m.toLowerCase(); m = m.toLowerCase();
var m2 = ''; var m2 = '';
let charcount = 0;
for(let i=0;((i<m.length)&&(m2.length<17));++i) { for(let i=0;((i<m.length)&&(m2.length<17));++i) {
let c = m.charAt(i); let c = m.charAt(i);
if ("0123456789abcdef".indexOf(c) >= 0) { if ("0123456789abcdef".indexOf(c) >= 0) {
m2 += c; m2 += c;
if ((m2.length > 0)&&(m2.length !== 17)&&((m2.length & 1) === 0)) charcount++;
if ((m2.length > 0)&&(m2.length !== 17)&&(charcount >= 2) ) {
m2 += ':'; m2 += ':';
charcount=0;
}
} }
} }
return m2; return m2;