From 4aac40099a5815db12bacb7f487bccc3a7844443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Tue, 26 Dec 2017 10:13:08 +0100 Subject: [PATCH] fix bssid cleaning. also, convert to uppercase --- src/c3nav/routing/locator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/c3nav/routing/locator.py b/src/c3nav/routing/locator.py index 858db6ef..ad76bdf1 100644 --- a/src/c3nav/routing/locator.py +++ b/src/c3nav/routing/locator.py @@ -205,8 +205,11 @@ class LocatorPoint(namedtuple('LocatorPoint', ('x', 'y', 'values'))): keys = frozenset(data.keys()) if (keys - cls.allowed_keys) or (cls.needed_keys - keys): raise ValidationError(_('Invalid Scan. Missing or forbidden keys.')) + if not isinstance(data['bssid'], str): + raise ValidationError(_('Invalid Scan. BSSID not a String.')) + data['bssid'] = data['bssid'].upper() if not re.match(r'^([0-9A-F]{2}:){5}[0-9A-F]{2}$', data['bssid']): - raise ValidationError(_('Invalid Scan. Invalid ESSID.')) + raise ValidationError(_('Invalid Scan. Invalid BSSID.')) if not isinstance(data['level'], int) or not (-1 >= data['level'] >= -100): raise ValidationError(_('Invalid Scan. Invalid RSSI/Level.')) if data['frequency'] not in cls.valid_frequencies: