nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

Home Page:https://nodemcu.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

enduser_setup module fails for open wifi networks

blobule opened this issue · comments

Expected behavior

Using enduser_setup, selecting an open network (one without password) is expected to work, but results in 400 bad request error instead.

Actual behavior

Selecting an open network result in a 400 bad request error.
This is due to the fact that the enduser_setup.html page will explicitly disable the password field for open networks. This results in a form that is submitted without the wifi_password field, which is expected to always be there in enduser_setup.c, in function enduser_setup_http_handle_credentials(), line 837:

if (name_str == NULL || pwd_str == NULL)
  {
    ENDUSER_SETUP_DEBUG("Password or SSID string not found");
    return 1;
  }

This "return 1" results in function enduser_setup_handle_POST replying a 400 bad request response.

All that is needed is to remove pwd_str==NULL from the test, and create an empty string instead when pwd_str is NULL.

Test code

Setup a wifi network without password, then do as in the documentation:

enduser_setup.start()

Select the network in the browser page. Notice that the submitted request has no wifi_password field. Error 400 will follow.

I don't have a working copy of nodemcu myself, so I cant submit a pull request. I hope someone can just fix this directly, as this is a simple bug.

NodeMCU startup banner

NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
	branch: release
	commit: 4f6792773f93f36a7255cfd28dca7aa6c4aa9552
	release: 3.0-release_20201107
	release DTS: 202011071523
	SSL: false
	build type: float
	LFS: 0x0 bytes total capacity
	modules: adc,bit,encoder,enduser_setup,file,gpio,i2c,mdns,mqtt,net,node,rtcmem,rtctime,sntp,tmr,uart,wifi
 build 2021-01-03 22:57 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)

Hardware

Esp8266 on a wemos d1 pro. Not very relevant for this bug...

Maybe it would be better to change enduser_setup.html to not disable but to hide the password field. Meaning to have a hidden input field

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.