UI improvements and input validations

This commit is contained in:
Matthew Grotke 2026-05-20 04:06:50 -04:00
parent b8c4914a52
commit 270856b391
22 changed files with 1548 additions and 302 deletions

View file

@ -153,9 +153,13 @@ def ip_or_cidr(value, max_len=49):
except ValueError:
return ''
def mac(value, max_len=17):
"""MAC address: hex digits and colons."""
return _strip(value.upper(), r'[^0-9A-F:]', max_len)
def mac(value):
"""MAC address in aa:bb:cc:dd:ee:ff format. Colons required; no other separators accepted.
Returns lowercase colon-separated MAC if valid, '' otherwise."""
s = str(value).strip().lower()
if re.fullmatch(r'([0-9a-f]{2}:){5}[0-9a-f]{2}', s):
return s
return ''
def url(value, max_len=500):
"""URL: printable ASCII except quotes, braces, brackets, backslash, spaces."""