mirror of https://git.48k.eu/ogcp
views: check invalid values in prettify_mac()
Return without modification if the MAC is not valid.master
parent
320df7ec0c
commit
c333b3ee56
|
@ -99,9 +99,6 @@ class ServerErrorCode(Exception):
|
|||
def normalize_mac(mac):
|
||||
return mac.replace(':', '').replace('-', '').replace('.', '').lower()
|
||||
|
||||
def prettify_mac(mac):
|
||||
return (':'.join(mac[i:i+2] for i in range(0, 12, 2))).lower()
|
||||
|
||||
def is_valid_normalized_mac(mac):
|
||||
if len(mac) != 12:
|
||||
return False
|
||||
|
@ -109,6 +106,13 @@ def is_valid_normalized_mac(mac):
|
|||
return False
|
||||
return True
|
||||
|
||||
def prettify_mac(mac):
|
||||
normalized_mac = normalize_mac(mac)
|
||||
|
||||
if not is_valid_normalized_mac(normalized_mac):
|
||||
return mac
|
||||
return (':'.join(normalized_mac[i:i+2] for i in range(0, 12, 2))).lower()
|
||||
|
||||
def ogserver_down(view):
|
||||
flash(_('Cannot talk to ogserver. Is ogserver down?'), category='error')
|
||||
return redirect(url_for(view))
|
||||
|
|
Loading…
Reference in New Issue