From 587bc8cb9f693357c51b27ebddfe8cfd46d2e8d4 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sun, 22 Feb 2026 13:10:34 +0100 Subject: [PATCH] fix: Validate GPS coordinates from advert payloads Discard NaN, Infinity, and out-of-range lat/lon values from struct.unpack to prevent JSON parse errors in browser. Co-Authored-By: Claude Opus 4.6 --- app/contacts_cache.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/contacts_cache.py b/app/contacts_cache.py index 94fd1a4..d8b1ba7 100644 --- a/app/contacts_cache.py +++ b/app/contacts_cache.py @@ -11,6 +11,7 @@ Each line: {"public_key": "...", "name": "...", "first_seen": ts, "last_seen": t import json import logging +import math import struct import time from pathlib import Path @@ -184,6 +185,11 @@ def parse_advert_payload(pkt_payload_hex: str): if has_location: if len(raw) >= 109: lat, lon = struct.unpack('