fix(wifi): use data-ssid for scan-list autofill so SSIDs with spaces connect - #45
Open
terahertz5k wants to merge 1 commit into
Open
fix(wifi): use data-ssid for scan-list autofill so SSIDs with spaces connect#45terahertz5k wants to merge 1 commit into
terahertz5k wants to merge 1 commit into
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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