fix(wifi): use data-ssid for scan-list autofill so SSIDs with spaces connect - #45
Conversation
…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.
|
Thanks @terahertz5k — root cause confirmed against the pinned WiFiManager v2.0.17: I extracted the embedded JS from the branch and ran it: the data-ssid path preserves real spaces, One tiny note, non-blocking: the NBSP CI never actually built this branch (the run sat queued until it timed out), but it's a single string-literal change and I've verified the JS independently. Landing this — thanks for the clean writeup. |
…se automation - Bump AUTO_VERSION to v2.9.6-pre across all envs - README: honest S3 (~50-55 KH/s, software-verified) and C3 (pending validation) numbers; old 280-400 KH/s figures were invalid shares - CHANGELOG entry for everything in this batch (SneezeGUI#36 SneezeGUI#37 SneezeGUI#38 SneezeGUI#39 SneezeGUI#44 SneezeGUI#45) - build.yml: upload factory-bin test builds on every PR - release.yml: tag-triggered build of all 17 targets + GitHub Release with factory/firmware bins (uses post_build_merge.py output) Co-Authored-By: Claude <noreply@anthropic.com>
Problem
Picking a network from the config portal's scan list makes the device fail to join any AP whose name contains a space. It fails with disconnect reason
201(WIFI_REASON_NO_AP_FOUND) even though the AP is present and the password is correct. Typing the same SSID by hand works — which makes this look like a router, signal, or credential problem rather than a portal bug.Root cause
wifi_manager_init()injects a customc(l)handler throughsetCustomHeadElement()that fills the SSID field frominnerText:Since
_customHeadElementis appended after the bundledHTTP_SCRIPT, this overrides WiFiManager's ownc().WiFiManager renders each scan-list entry from
HTTP_ITEM:populating the two tokens differently:
and
htmlEntities(str, whitespace=true)doesstr.replace(" ", " ").So the visible link text carries U+00A0 (non-breaking space) while
data-ssidkeeps real0x20spaces. ReadinginnerTextsubmitsMy<U+00A0>Network, which never matches the real SSID during the scan — henceNO_AP_FOUNDrather than an auth error.This is precisely why WiFiManager's own handler reads
data-ssidfirst.Fix
Read
data-ssidfirst, falling back toinnerText/textContentwith U+00A0 normalized in case a future WiFiManager version drops the attribute.Testing
Verified on an ESP32-2432S028 (CYD, 2-USB) against a WPA2 network whose SSID contains a space:
[WIFI] Disconnected, reason: 201and never associated.c().The portal code is shared, so this affects all boards.
Notes
l.nextElementSiblingpassword-field enable/disable logic; this change keeps that as-is rather than widening scope.🤖 Generated with Claude Code