From: Jorge Turrado Ferrero <36899226+JorTurFer@users.noreply.github.com> Date: Wed, 25 Jul 2018 14:20:25 +0000 Subject: Update wol.py X-Git-Url: https://publicrepos.bentasker.co.uk/projects/Wake-On-Lan-Python.git/commitdiff/b3a3a2e6adbebe1f8a8348f64b4136e1579e989e --- Update wol.py Use regular expressions to validate de mac also --- --- a/wol.py +++ b/wol.py @@ -32,13 +32,13 @@ return False # Check macaddress format and try to compensate. - if len(macaddress) == 12: + if re.match('([a-fA-F0-9]{2}){6}',macaddress): pass else: # Use regular expression to extract not usable chars macaddress = re.sub('[^A-F0-9]', '', macaddress,flags=re.IGNORECASE) # Re-check the value - if len(macaddress) == 12: + if re.match('([a-fA-F0-9]{2}){6}',macaddress): pass else: raise ValueError('Incorrect MAC address format')