Skip to content

SSID is not properly sanitized #2609

Todo

Description

@qwerty123443

What happened?

I named my router "<script>alert(1)</script>" because I thought it'd be funny, and sometimes I run into websites that randomly break :) In this case, navigating to the wifi settings page caused it.
image

To Reproduce Bug

Set your router's SSID to something containing the string "</script>" and navigate to the wifi settings page

Expected Behavior

I expect the page to be properly displayed

Install Method

Binary from WLED.me

What version of WLED?

0.13.1

Which microcontroller/board are you seeing the problem on?

ESP8266

Relevant log/trace output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added this to the milestone on Mar 31, 2022
  2. stale commented on Sep 21, 2022

    @stale

    Hey! This issue has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs.
    Thank you for using WLED!

  3. added
    stale
    on Sep 21, 2022
  4. added
    keep
    and removed
    stale
    on Sep 23, 2022
  5. vladtepesch commented on Dec 25, 2022

    @vladtepesch
  6. modified the milestones: , 16.1 on Jan 20, 2026
  7. modified the milestones: 16.1, 16.2 on Nov 22, 2026
  8. softhack007 commented on Dec 2, 2026

    @softhack007
    Member

    @coderabbitai does the current code still support this hack?

  9. coderabbitai commented on Dec 2, 2026

    @coderabbitai
    Contributor
    Analysis chain

    Script executed:

    #!/bin/bash
    set -o pipefail
    echo "=== Repository revision ==="
    git rev-parse HEAD
    git branch --show-current
    echo "=== Issue ==="
    gh api repos/wled/WLED/issues/2609 --jq '{number,title,body,state,html_url,created_at,updated_at}'
    echo "=== Comments ==="
    gh api --paginate repos/wled/WLED/issues/2609/comments --jq '.[] | {user:.user.login,created_at,body,html_url}'

    Length of output: 2461


    Script executed:

    #!/bin/bash
    echo "=== Default branch ==="
    gh api repos/wled/WLED --jq '{default_branch}'
    echo "=== SSID and Wi-Fi settings references ==="
    rg -n -i -C 2 'ssid|settings_wifi|wifi scan' wled00 --glob '!*.h.json' --glob '!*.map' | head -n 450
    echo "=== Candidate Wi-Fi settings files ==="
    fd -i 'settings_wifi|wifi' .

    Length of output: 25888


    Script executed:

    #!/bin/bash
    echo "=== Revisions ==="
    git rev-parse HEAD
    gh api repos/wled/WLED/branches/main --jq '.commit.sha'
    echo "=== Outlines ==="
    ast-grep outline wled00/xml.cpp --items all
    ast-grep outline wled00/wled_server.cpp --items all --match 'settings|Settings|serve'
    ast-grep outline wled00/data/settings_wifi.htm --items all || true
    echo "=== Script creation and serving references ==="
    rg -n -C 3 'settingsScript|generateSettings|/settings|addWiFi\(|getSettings|innerHTML|loadJS' wled00/xml.cpp wled00/wled_server.cpp wled00/data/settings_wifi.htm wled00/data/common.js wled00/data/settings.htm 2>/dev/null
    echo "=== Numbered source excerpts ==="
    cat -n wled00/xml.cpp | sed -n '1,115p;175,270p'
    cat -n wled00/data/settings_wifi.htm | sed -n '1,180p;200,275p'
    cat -n wled00/wled_server.cpp | sed -n '750,885p'

    Length of output: 83947


    Script executed:

    #!/bin/bash
    echo "=== Settings JavaScript response ==="
    cat -n wled00/wled_server.cpp | sed -n '715,745p'
    echo "=== JavaScript loading ==="
    cat -n wled00/data/common.js | sed -n '112,150p'
    echo "=== Stored and scanned network handling ==="
    cat -n wled00/set.cpp | sed -n '20,52p'
    cat -n wled00/json.cpp | sed -n '1050,1090p'

    Length of output: 6828


    @softhack007 The reported SSID <script>alert(1)</script> should no longer break the page or trigger the alert, based on the current code. The settings data is now served as a separate JavaScript resource, so </script> does not close an inline script element.

    SSID handling is still unsafe for other values:

    • getSettingsJS() inserts the saved SSID into JavaScript without escaping it. A quote can break the script, and a crafted saved SSID can inject JavaScript.
    • addWiFi() also inserts the SSID into HTML without escaping it. For example, an SSID containing &amp; can display as &.

    I checked main at 0e1f77a. This is a code inspection; I did not test it on a device or in a browser.


    Learnings used

    Learnt from: softhack007
    Repo: wled/WLED PR: 0
    File: :0-0
    Timestamp: 2026-10-03T14:59:43.661Z
    Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
    

    You are interacting with an AI system.

  10. softhack007 commented on Dec 2, 2026

    @softhack007
    Member

    @coderabbitai would we need to create our own "escape string" function, or is there a function in the framework - or in JS for the UI part - that we could use?

  11. coderabbitai commented on Dec 2, 2026

    @coderabbitai
    Contributor
    Analysis chain

    Script executed:

    #!/bin/bash
    echo '=== Revision ==='
    git rev-parse HEAD
    echo '=== Candidate source files ==='
    fd -i '^(xml\.cpp|settings_wifi\.htm|common\.js|platformio\.ini|AGENTS\.md)$' .
    echo '=== Relevant outlines ==='
    ast-grep outline wled00/xml.cpp --items all --match 'Settings|escape|Escape|JSON|JS' || true
    ast-grep outline wled00/data/common.js --items all --match 'escape|Escape|html|Html|text|Text' || true
    ast-grep outline wled00/data/settings_wifi.htm --items all || true
    echo '=== Escaping and serialization helpers ==='
    rg -n -i -C 2 'escape(html|xml|json|js|javascript|string)|htmlencode|encodehtml|serializeJson|jsonserialize|textContent|createTextNode|createElement\(' wled00 --glob '!html_*.h' --glob '!js_*.h' --glob '!*.min.js' | head -n 260
    echo '=== JSON library references ==='
    rg -n -i -C 2 'ArduinoJson|lib_deps|arduinojson' platformio.ini wled00 -g '*.{ini,cpp,h}' | head -n 130
    echo '=== Relevant code ==='
    cat -n wled00/xml.cpp | sed -n '1,120p;200,270p'
    cat -n wled00/data/settings_wifi.htm | sed -n '90,180p'
    cat -n wled00/data/common.js | sed -n '1,180p'

    Length of output: 45719


    Script executed:

    #!/bin/bash
    echo '=== ArduinoJson source files ==='
    fd -i 'ArduinoJson|version\.hpp|JsonDocument' . | head -n 100
    echo '=== ArduinoJson includes, versions and serialize calls ==='
    rg -n -i -C 2 'ARDUINOJSON_VERSION|ArduinoJson\.h|serializeJson\(' --glob '*.{h,hpp,cpp,ini,json}' | head -n 180
    echo '=== Settings value helpers ==='
    rg -n -C 3 'printSetFormValue\s*\(' wled00 | head -n 100
    echo '=== Existing HTML escaper usages ==='
    rg -n -C 2 '\besc\s*\(' wled00/data --glob '!*.min.js' | head -n 100
    echo '=== WiFi scan code ==='
    cat -n wled00/data/settings_wifi.htm | sed -n '15,90p'

    Length of output: 21725


    Script executed:

    #!/bin/bash
    echo '=== Bundled version ==='
    rg -n -m 10 'ARDUINOJSON_VERSION|VERSION_MAJOR|VERSION_MINOR|VERSION_REVISION' wled00/src/dependencies/json/ArduinoJson-v6.h
    echo '=== Serializer and escaping implementation locations ==='
    rg -n -C 3 'class JsonSerializer|struct JsonSerializer|writeString|EscapeSequence|escapeChar|class TextFormatter|writeRaw|writeUnicode' wled00/src/dependencies/json/ArduinoJson-v6.h | head -n 180
    echo '=== String assignment examples ==='
    rg -n -C 2 '\b(doc|json|[a-zA-Z]+Doc)\.set\s*\(' --glob '*.{cpp,h}' | head -n 60
    echo '=== Settings helpers ==='
    ast-grep outline wled00/util.cpp --items all --match 'printSetForm'
    cat -n wled00/util.cpp | sed -n '120,160p'

    Length of output: 8481


    Script executed:

    #!/bin/bash
    echo '=== Bundled escape table ==='
    cat -n wled00/src/dependencies/json/ArduinoJson-v6.h | sed -n '5378,5425p;6140,6170p;6420,6450p;6478,6491p'
    echo '=== Bundled root document set API ==='
    rg -n -C 3 'class JsonDocument|class StaticJsonDocument|bool set\(const T|set\(const T' wled00/src/dependencies/json/ArduinoJson-v6.h | head -n 100

    Length of output: 6183


    @softhack007 We probably do not need a new HTML escape function. The firmware side needs a separate solution because it generates JavaScript, not HTML.

    • UI: common.js already provides esc(). In addWiFi(), it can escape the SSID for the quoted HTML attribute:

      value="${esc(ssid)}"

      Apply the same treatment to the enterprise identity fields. Alternatively, create the inputs and assign their .value properties directly. I followed the repository guidance to reuse common.js helpers.

    • Firmware: WLED bundles ArduinoJson 6.18.1. Its serializeJson() can write a quoted string literal to settingsScript, so it can replace the raw %s insertion. Do not add another pair of quotes around its output. The SSID and enterprise identity strings need this treatment; printSetFormValue() also needs attention for other string settings.

    There is one limitation: the bundled serializer writes some control characters raw. If we need valid JSON for arbitrary control characters, we need validation or a serializer that escapes all of them.

    The UI escape alone cannot fix injection in the generated JavaScript: the firmware must serialize the values safely first. I inspected the code but did not test this on a device or in a browser.


    Learnings used

    Learnt from: CR
    Repo: wled/WLED PR: 0
    File: CONTRIBUTING.md:0-0
    Timestamp: 2026-10-31T16:42:25.881Z
    Learning: Applies to wled00/data/index.js : Applicability reference:
    AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
    ## Required User Agreement
    ### No agent-posted replies or issues
    Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
    
    - Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
    
    Source excerpt:
    # Thank you for making WLED better!
    
    ## Coding Guidelines
    
    ### Code style
    
    #### Indentation
    
    We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.  
    You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
    
    Learnt from: CR
    Repo: wled/WLED PR: 0
    File: CONTRIBUTING.md:0-0
    Timestamp: 2026-10-31T16:42:25.881Z
    Learning: Applies to wled00/data/common.js : Applicability reference:
    AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
    ## Required User Agreement
    ### No agent-posted replies or issues
    Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
    
    - Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
    
    Source excerpt:
    # Thank you for making WLED better!
    
    ## Coding Guidelines
    
    ### Code style
    
    #### Indentation
    
    We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.  
    You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
    
    Learnt from: CR
    Repo: wled/WLED PR: 0
    File: AGENTS.md:0-0
    Timestamp: 2026-12-02T16:50:37.145Z
    Learning: Applies to wled00/data/** : Source excerpt:
    # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
    
    ## Web UI Code Style (wled00/data/)
    
    - **Tab indentation** for HTML, JS, and CSS
    - camelCase for JS functions/variables
    - Reuse helpers from `common.js` — do not duplicate utilities
    
    Learnt from: softhack007
    Repo: wled/WLED PR: 0
    File: :0-0
    Timestamp: 2026-10-03T14:59:43.661Z
    Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
    

    You are interacting with an AI system.

  12. coderabbitai commented on Dec 2, 2026

    @coderabbitai
    Contributor
    Analysis chain

    Script executed:

    #!/bin/bash
    echo '=== Revision ==='
    git rev-parse HEAD
    echo '=== Source outlines ==='
    ast-grep outline wled00/xml.cpp --items all --match 'Settings|settings' || true
    ast-grep outline wled00/util.cpp --items all --match 'printSetForm' || true
    ast-grep outline wled00/data/common.js --items all --match '^esc$' || true
    echo '=== Wi-Fi settings data and escaping ==='
    rg -n -C 3 'function esc\b|function addWiFi\b|addWiFi\(|settingsScript|printSetFormValue\s*\(' wled00/data/common.js wled00/data/settings_wifi.htm wled00/xml.cpp wled00/util.cpp | head -n 240
    echo '=== Browser code ==='
    cat -n wled00/data/common.js | sed -n '145,165p'
    cat -n wled00/data/settings_wifi.htm | sed -n '110,155p'
    echo '=== ArduinoJson version and escape implementation ==='
    rg -n -m 8 'ARDUINOJSON_VERSION|class EscapeSequence|class TextFormatter|class JsonSerializer' wled00/src/dependencies/json/ArduinoJson-v6.h
    cat -n wled00/src/dependencies/json/ArduinoJson-v6.h | sed -n '5375,5425p;6140,6175p;6420,6455p'
    echo '=== Server settings script serving ==='
    cat -n wled00/wled_server.cpp | sed -n '715,745p'

    Length of output: 26380


    @softhack007 We can reuse existing functions for most of this:

    • UI: esc() in common.js escapes text for a quoted HTML attribute. For example, use value="${esc(ssid)}" in addWiFi(). Apply it to the other string values inserted into HTML too. Alternatively, create the inputs and assign their .value properties. The repository guidance favors reusing common.js helpers.
    • Firmware: The bundled ArduinoJson 6.18.1 can use serializeJson() to write a quoted string literal to the settings JavaScript. Do not add another pair of quotes around its output.

    The bundled serializer does not escape every control character. If those characters must be preserved, we need a different serializer or our own escaping function. UI escaping alone cannot fix unsafe JavaScript generated by the firmware.

    I inspected the code at 0e1f77a. I did not test this in a browser or on a device.


    Learnings used

    Learnt from: CR
    Repo: wled/WLED PR: 0
    File: CONTRIBUTING.md:0-0
    Timestamp: 2026-10-31T16:42:25.881Z
    Learning: Applies to wled00/data/common.js : Applicability reference:
    AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
    ## Required User Agreement
    ### No agent-posted replies or issues
    Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
    
    - Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
    
    Source excerpt:
    # Thank you for making WLED better!
    
    ## Coding Guidelines
    
    ### Code style
    
    #### Indentation
    
    We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.  
    You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
    
    Learnt from: CR
    Repo: wled/WLED PR: 0
    File: AGENTS.md:0-0
    Timestamp: 2026-12-02T16:50:37.145Z
    Learning: Applies to wled00/data/** : Source excerpt:
    # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
    
    ## Web UI Code Style (wled00/data/)
    
    - **Tab indentation** for HTML, JS, and CSS
    - camelCase for JS functions/variables
    - Reuse helpers from `common.js` — do not duplicate utilities
    
    Learnt from: softhack007
    Repo: wled/WLED PR: 0
    File: :0-0
    Timestamp: 2026-10-03T14:59:43.661Z
    Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
    

    You are interacting with an AI system.

  13. softhack007 commented on Dec 2, 2026

    @softhack007
    Member

    @coderabbitai please check if other UI fields and settings will also need escaping, to prevent unexpected behaviour.

  14. coderabbitai commented on Dec 2, 2026

    @coderabbitai
    Contributor
    Analysis chain

    Script executed:

    #!/bin/bash
    echo '=== Revision ==='
    git rev-parse HEAD
    echo '=== Candidate source outlines ==='
    ast-grep outline wled00/xml.cpp --items all --match 'Settings|settings' 
    ast-grep outline wled00/util.cpp --items all --match 'printSetForm'
    ast-grep outline wled00/data/common.js --items all --match 'esc|load'
    echo '=== All settings string generation calls ==='
    rg -n -C 1 'printSetFormValue\s*\(|settingsScript\s*(\+=|=)|sappend\s*\(' wled00/xml.cpp wled00/util.cpp
    echo '=== UI source candidates ==='
    fd -t f -e htm -e html -e js . wled00/data | grep -vE '(iro\.js|rangetouch\.js|omggif\.js|\.min\.js|icons-ui)' 
    echo '=== Dynamic HTML assignments ==='
    rg -n -g '*.{js,htm,html}' -g '!*.min.js' -g '!iro.js' -g '!rangetouch.js' -g '!omggif.js' -g '!**/icons-ui/**' '\b(innerHTML|outerHTML|insertAdjacentHTML|document\.write)\b' wled00/data
    echo '=== Settings source string format patterns ==='
    rg -n -C 1 '(%s|String\s*\(|\.c_str\(\))' wled00/xml.cpp wled00/util.cpp

    Length of output: 36892


    Script executed:

    #!/bin/bash
    echo '=== Revision ==='
    git rev-parse HEAD
    echo '=== Candidate source outlines ==='
    ast-grep outline wled00/xml.cpp --items all --match 'Settings|settings'
    ast-grep outline wled00/util.cpp --items all --match 'printSetForm'
    ast-grep outline wled00/data/common.js --items all --match 'esc|load'
    echo '=== All settings string generation calls ==='
    rg -n -C 1 'printSetFormValue\s*\(|settingsScript\s*(\+=|=)|sappend\s*\(' wled00/xml.cpp wled00/util.cpp
    echo '=== UI source candidates ==='
    fd -t f -e htm -e html -e js . wled00/data | grep -vE '(iro\.js|rangetouch\.js|omggif\.js|\.min\.js|icons-ui)'
    echo '=== Dynamic HTML assignments ==='
    rg -n -g '*.{js,htm,html}' -g '!*.min.js' -g '!iro.js' -g '!rangetouch.js' -g '!omggif.js' -g '!**/icons-ui/**' '\b(innerHTML|outerHTML|insertAdjacentHTML|document\.write)\b' wled00/data
    echo '=== Settings source string format patterns ==='
    rg -n -C 1 '(%s|String\s*\(|\.c_str\(\))' wled00/xml.cpp wled00/util.cpp

    Length of output: 36890


    Script executed:

    #!/bin/bash
    echo '=== Source maps ==='
    for f in wled00/data/index.js wled00/data/settings_um.htm wled00/data/settings_time.htm wled00/data/settings_ui.htm wled00/data/settings_wifi.htm wled00/data/settings_leds.htm wled00/set.cpp wled00/data/pixelforge/pixelforge.htm; do
      echo "--- $f"; ast-grep outline "$f" --items all 2>/dev/null | head -n 100
    done
    echo '=== Settings data, controls and validation ==='
    cat -n wled00/xml.cpp | sed -n '203,295p;510,518p;570,598p;636,654p;686,711p'
    cat -n wled00/util.cpp | sed -n '135,160p'
    rg -n -C 2 'serverDescription|apSSID|cmDNS|alexaInvocationName|mqttServer|mqttUser|mqttClientID|mqttDeviceTopic|mqttGroupTopic|ntpServerName|getCustomText|linked_remotes' wled00/set.cpp wled00/json.cpp wled00/cfg.cpp
    echo '=== Main UI named text ==='
    cat -n wled00/data/index.js | sed -n '390,505p;565,660p;805,900p;1168,1190p'
    echo '=== Settings UI generators ==='
    cat -n wled00/data/settings_um.htm | sed -n '1,90p;160,260p'
    cat -n wled00/data/settings_time.htm | sed -n '35,90p;94,170p'
    cat -n wled00/data/settings_ui.htm | sed -n '35,120p'
    echo '=== Other candidates ==='
    cat -n wled00/data/settings_wifi.htm | sed -n '15,90p;110,190p'
    cat -n wled00/data/pixelforge/pixelforge.htm | sed -n '765,805p'

    Length of output: 76208


    Script executed:

    #!/bin/bash
    echo '=== Usermod field building ==='
    cat -n wled00/data/settings_um.htm | sed -n '90,135p'
    echo '=== Preset and segment rendering ==='
    cat -n wled00/data/index.js | sed -n '590,650p;750,805p;1070,1098p;1960,1985p;2060,2152p;2165,2198p;2230,2245p'
    echo '=== Related name sources and sinks ==='
    rg -n -C 2 'pName\(|qlName\(|inst\.n|serverDescription|\bsd\b|setSegName|seg.*\.n|["\x27]n["\x27]' wled00/data/index.js wled00/data/settings_sec.htm wled00/json.cpp wled00/set.cpp | head -n 250
    echo '=== Firmware settings input validation ==='
    cat -n wled00/set.cpp | sed -n '20,60p;100,118p;150,168p;470,480p;545,568p;594,603p'
    echo '=== UI settings data and usermod source ==='
    cat -n wled00/data/settings_ui.htm | sed -n '1,35p;120,180p'
    rg -n -C 2 'addInfo\(|addI\(|addDropdown\(|addO\(' wled00 --glob '*.{cpp,h}' | head -n 90
    echo '=== Common HTML helper usage in main UI ==='
    rg -n -C 2 '\besc\s*\(|common\.js|htmlEscape|escapeHtml' wled00/data/index.js wled00/data/index.htm wled00/data/common.js
    echo '=== XML description output ==='
    cat -n wled00/xml.cpp | sed -n '1,32p;40,53p'

    Length of output: 40350


    Script executed:

    #!/bin/bash
    echo '=== Settings helper call sites across repository ==='
    rg -n -C 1 '\b(printSetFormValue|printSetClassElementHTML)\s*\(' --glob '*.{cpp,h}' | grep -vE '^wled00/xml\.cpp|^wled00/util\.cpp' | head -n 140
    echo '=== Main UI script loading ==='
    rg -n -C 2 '<script|common\.js|index\.js|function esc' wled00/data/index.htm wled00/data/index.js wled00/wled_server.cpp
    echo '=== Usermod config value handling ==='
    rg -n -C 2 'case SUBPAGE_UM|umCfg|json\.um|strlcpy\(.*request->arg|enterpriseAnonIdentity|enterpriseIdentity' wled00/set.cpp wled00/data/settings_um.htm | head -n 180
    echo '=== Usermod settings string examples ==='
    rg -n -C 2 'addToConfig|readFromConfig' usermods -g '*.{cpp,h}' | head -n 75
    echo '=== Main UI info and ledmap labels ==='
    cat -n wled00/data/index.js | sed -n '700,742p;900,925p;2115,2128p'
    echo '=== JSON configuration handling in UI settings ==='
    cat -n wled00/data/settings_ui.htm | sed -n '69,107p'

    Length of output: 22454


    @softhack007 Yes. I found other fields that need output handling beyond the Wi-Fi SSID.

    Firmware-generated JavaScript

    • The string overload of printSetFormValue() inserts values without JavaScript escaping. It affects the AP SSID, mDNS name, device name, Alexa name, MQTT server/user/client ID/topics, NTP server and LED bus custom text. A double quote can break the settings script; a backslash can change the value.
    • The security page also inserts the device name separately. The ESP-NOW remote list has another direct insertion. Its browser-side MAC check happens after the script is parsed.

    Browser HTML

    Other output

    • The /win XML response inserts the device name without XML escaping. For example, & can make the XML invalid.

    I would serialize firmware values for the JavaScript context, then use DOM .value or .textContent for browser text where possible. For quoted HTML attributes, esc() is an option. The main UI does not currently load common.js, so it would need access to that helper first. This follows the repository guidance to reuse common helpers. The usermod generator also embeds keys in an inline JavaScript handler; HTML escaping alone is not sufficient for that nested context.

    Not every path needs the same change: the timer preset options already use esc(), and scanned Wi-Fi options use DOM properties.

    I inspected revision 0e1f77a. This was a targeted inspection, not a complete audit. I did not test it in a browser or on a device.


    Learnings used

    Learnt from: CR
    Repo: wled/WLED PR: 0
    File: AGENTS.md:0-0
    Timestamp: 2026-12-02T16:50:37.145Z
    Learning: Applies to wled00/data/** : Source excerpt:
    # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
    
    ## Web UI Code Style (wled00/data/)
    
    - **Tab indentation** for HTML, JS, and CSS
    - camelCase for JS functions/variables
    - Reuse helpers from `common.js` — do not duplicate utilities
    
    Learnt from: softhack007
    Repo: wled/WLED PR: 0
    File: :0-0
    Timestamp: 2026-10-03T14:59:43.661Z
    Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
    

    You are interacting with an AI system.

  15. softhack007 commented on Dec 2, 2026

    @softhack007
  16. coderabbitai commented on Dec 2, 2026

    @coderabbitai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugkeep

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions