tayfunulu / WiFiManager

WiFi manager for ESP8266 - ESP12 - ESP32 - micropython
MIT License
345 stars 104 forks source link

fix profile line / csv for delimiter char existing in values #6

Open ThomasWaldmann opened 6 years ago

ThomasWaldmann commented 6 years ago

currently ";" is used as csv delimiter. guess one will run into a problem if the ssid or password contains a ";".

tayfunulu commented 6 years ago

okey. whats is your suggestion to separate - tab, space or special character ?

ThomasWaldmann commented 6 years ago

well, we don't know what people put in their ssids / passwords - could be anything (anything except 0x00 maybe due to C limitations)?

so an easy solution could be to use 0x00 as separator - slightly ugly because we have a text file containing zero bytes then.

another way would be to just encode/decode the ssid / password part, e.g. using base64 (unreadable for humans) or some repr-like encoding and use any char as delimiter that is not in the possible encoder output values.

or give up csv and just use pickle.dump?

yeyeto2788 commented 6 years ago

Hey there, just passing by this repository and found this issue and it came to my mind that instead of saving it into CSV format maybe it can be saved into JSON format and if any special character needs to be saved why not escaping them?

Also it came to my mind to encode the password string as Base64 which for example:

"hello world!" will be converted into ImhlbGxvIHdvcmxkISI=

One limitation I see on the last option will be memory space used but it might be a way to handle any password with special characters

ThomasWaldmann commented 6 years ago

JSON is not directly usable as it can not have arbitrary bytes in it, so we would need to encode all stuff that can be arbitrary bytes (password, ssid, ...).

But if we encode that much, what's left? We could also use pickle if it is not readable anyway.