From 9045f8f030441cab153ad7badd5cd9fd66d9e7ff Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 16 Aug 2026 20:28:06 +0000 Subject: [PATCH] Fix DEVICE_MARKER_RE field order so list_extensions() actually finds devices DEVICE_MARKER_RE expected "; === Device: NAME [AA:marker] (category) ===", but device_config's own template (further down this file) generates "; === Device: NAME (category) [AA:marker] ===" -- category parens before the AA tag, not after. The regex never matched a real device comment, so list_extensions() silently returned [] for every device on every install, and /api/pstn-permissions served {"extensions": []} regardless of what was actually in pstn-permissions.conf. That's why the Extensions tab's Messaging/Voicemail checkboxes always rendered unchecked after a save + reload even though the file itself had messaging=yes/voicemail=yes written correctly -- the JS falls back to an all-default row when the endpoint returns nothing. ea_list_devices() and the rename-device code parse the same comment via string-splitting/a differently-shaped regex and were already correct; this was the one broken parser. --- services/security-dashboard.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/security-dashboard.sh b/services/security-dashboard.sh index 4070982..46a1061 100644 --- a/services/security-dashboard.sh +++ b/services/security-dashboard.sh @@ -1186,7 +1186,21 @@ ASN_FILTER_RE = re.compile(r"ASNNumber in \[([^\]]*)\]\)") ID_RE = re.compile(r"^\d+$") ASN_RE = re.compile(r"^\d+$") IP_RE = re.compile(r"^\d{1,3}(\.\d{1,3}){3}$") -DEVICE_MARKER_RE = re.compile(r"^; === Device: (.+?)(?:\s*\[AA:(?:yes|no)\])?\s*\((.+?)\)\s*===\s*$") +# Actual generated order (see device_config's "%s (%s) %s===" template +# further down this file) is NAME, then "(category)", then an optional +# "[AA:yes/no]" tag -- in that order. This regex previously expected the AA +# tag BEFORE the category parens, which never matches a real device comment +# and made list_extensions() return [] for every device on every box, +# regardless of migration history. Confirmed live: /api/pstn-permissions +# returned {"extensions": []} on a completely fresh install with one +# extension configured, which is why the Extensions tab's Messaging/ +# Voicemail checkboxes always render unchecked (the JS falls back to an +# all-default row when nothing comes back from that endpoint) even though +# pstn-permissions.conf itself has the correct messaging=yes/voicemail=yes +# written to disk. ea_list_devices() and _ea_rename_device_category() parse +# the same comment via string-splitting instead of a single regex and were +# never affected -- this file was the only broken parser. +DEVICE_MARKER_RE = re.compile(r"^; === Device: (.+?)\s*\(([^)]*)\)\s*(?:\[AA:(?:yes|no)\]\s*)?===\s*$") EXT_HEADER_RE = re.compile(r"^\[(\d+)\]") EXTEN_RE = re.compile(r"^\d+$") TIER_RE = re.compile(r"^(internal|restricted|full)$")