khoih-prog / WiFiWebServer

This is simple yet complete WebServer library for AVR, Portenta_H7, Teensy, SAM DUE, SAMD, STM32, RP2040-based, etc. boards running WiFi modules/shields (WiFiNINA, CYW43439, U-Blox W101, W102, etc.). The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32. Now using WiFiMulti_Generic library
MIT License
104 stars 21 forks source link

Decoding Error. two times called urlDecode in Parsing-impl.h. #17

Closed RQnet closed 2 years ago

RQnet commented 2 years ago

Describe the bug

if i use password with special charakters like "*%&%25%26**" with WiFiManager_NINA_lite V1.6.1 the decoding of this password is wrong. I got just "%". I use "GET" with urlDecoded value request.

Steps to Reproduce

just send this password *%&%25%26** with WiFiManager_NINA_lite

Problem

urlDecode(.....) is called two times. first in _parseRequest() -> urlDecode(...) second in _parseRequest() -> _parseArguments(...) -> (void)_parseArgumentsPrivate(data, storeArgHandler()); -> urlDecode(...)

the first call is decoding and the second decoding is trimming at the "&".

Solution

replace this line
searchStr = urlDecode(url.substring(hasSearch + 1));

with that line searchStr = url.substring(hasSearch + 1);

problem

solution

khoih-prog commented 2 years ago

Hi @RQnet

Thanks for your bug report and very detailed investigative information. I wish any bug report will be as good as this one from you.

I definitely will fix this hard-to-find bug, with a note for your contribution. If you have some more time, please help by doing some more tests to see if there are anymore bug relating to this duplicated use of urlDecode().

Regards,


PS:

You can also create a PR. If you're not familiar now, it's good time to start and be a PR master. Some unimportant note: it's better to post the code and terminal output in code tag, not picture.

I'm glad to see you've been moving forward quite fast from recent posts. Successfully debugging, which requires you read and understand the library code, will definitely help you a lot in the future.

khoih-prog commented 2 years ago

Hi @RQnet

The new WiFiWebServer releases v1.6.3 has just been published. Your contribution is noted in Contributions and Thanks

Best Regards,


Releases v1.6.3

  1. Fix decoding error bug when using special & in data fields. Check Decoding Error. two times called urlDecode in Parsing-impl.h. #17
  2. Update Packages' Patches
RQnet commented 2 years ago

Hi @khoih-prog, its my first time in microcontroller progrmming. so i needed a little bit of time to get knowledge. but i could get a good understand your clean coded implementation. thanks for fixing the bug and your really good work in your libraries. they are very helpfull! Best Regards