mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
Update device_handling.py
Fixes #1088 by sanitizing the inputs to mac, vendor, and name before running .upper/.lower to ensure they are type STR to avoid AttributeError
This commit is contained in:
@@ -674,9 +674,9 @@ def guess_icon(vendor, mac, ip, name, default):
|
|||||||
mylog('debug', [f"[guess_icon] Guessing icon for (vendor|mac|ip|name): ('{vendor}'|'{mac}'|{ip}|{name})"])
|
mylog('debug', [f"[guess_icon] Guessing icon for (vendor|mac|ip|name): ('{vendor}'|'{mac}'|{ip}|{name})"])
|
||||||
|
|
||||||
result = default
|
result = default
|
||||||
mac = mac.upper()
|
mac = str(mac).upper() if mac else "00:00:00:00:00:00"
|
||||||
vendor = vendor.lower() if vendor else "unknown"
|
vendor = str(vendor).lower() if vendor else "unknown"
|
||||||
name = name.lower() if name else "(unknown)"
|
name = str(name).lower() if name else "(unknown)"
|
||||||
|
|
||||||
# Guess icon based on vendor
|
# Guess icon based on vendor
|
||||||
if any(brand in vendor for brand in {"samsung", "motorola"}):
|
if any(brand in vendor for brand in {"samsung", "motorola"}):
|
||||||
@@ -732,8 +732,8 @@ def guess_icon(vendor, mac, ip, name, default):
|
|||||||
# Guess device type
|
# Guess device type
|
||||||
def guess_type(vendor, mac, ip, name, default):
|
def guess_type(vendor, mac, ip, name, default):
|
||||||
result = default
|
result = default
|
||||||
mac = mac.upper()
|
mac = str(mac).upper() if mac else "00:00:00:00:00:00"
|
||||||
vendor = vendor.lower() if vendor else "unknown"
|
vendor = str(vendor).lower() if vendor else "unknown"
|
||||||
name = str(name).lower() if name else "(unknown)"
|
name = str(name).lower() if name else "(unknown)"
|
||||||
|
|
||||||
# Guess icon based on vendor
|
# Guess icon based on vendor
|
||||||
|
|||||||
Reference in New Issue
Block a user