From b04659888ab9600bacf63047c49c9d2f04d38de1 Mon Sep 17 00:00:00 2001 From: "kevin.lui" Date: Thu, 30 Jul 2026 17:09:51 -0700 Subject: [PATCH] fix(wifi): use data-ssid for scan-list autofill so SSIDs with spaces connect Clicking a network in the config portal's scan list filled the SSID field from the link's innerText. WiFiManager renders that visible text with htmlEntities(ssid, true), which replaces every space with   (U+00A0 non-breaking space), so the submitted SSID never matched the real network. Any AP whose name contains a space therefore failed to join with reason 201 (NO_AP_FOUND), while typing the same SSID by hand worked -- which made the failure look like a credential, router or signal problem. Read the data-ssid attribute first, the same source WiFiManager's own bundled c() handler uses; it is populated with htmlEntities(ssid) and keeps real spaces. Normalize U+00A0 on the innerText/textContent fallbacks in case data-ssid is unavailable. --- src/config/wifi_manager.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/config/wifi_manager.cpp b/src/config/wifi_manager.cpp index bbe8e4b..b4d179f 100644 --- a/src/config/wifi_manager.cpp +++ b/src/config/wifi_manager.cpp @@ -412,8 +412,19 @@ void wifi_manager_init() { "});" // Run sync after DOM is fully loaded "if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',syncDropdowns);}else{syncDropdowns();}" - // SSID auto-fill when clicking network link - "function c(l){console.log('[SSID] Clicked: '+l.innerText);var s=document.querySelector('input[name=\"s\"]');if(s){s.value=l.innerText||l.textContent;console.log('[SSID] Set to: '+s.value);}}" + // SSID auto-fill when clicking network link. + // Read data-ssid first: WiFiManager renders the *visible* link text with + // htmlEntities(ssid, true), which turns every space into   (U+00A0 + // non-breaking space). Using innerText therefore submits an SSID the + // ESP32 scan can never match, failing with reason 201 (NO_AP_FOUND) on + // any network whose name contains a space. data-ssid keeps real spaces. + "function c(l){" + "var s=document.querySelector('input[name=\"s\"]');" + "if(s){" + "var v=l.getAttribute('data-ssid')||l.innerText||l.textContent||'';" + "s.value=v.replace(/\\u00a0/g,' ');" // normalize NBSP on fallback paths + "console.log('[SSID] Set to: '+JSON.stringify(s.value));" + "}}" ""; s_wm.setCustomHeadElement(customCSS);