GET parameter retrieval and Unicode decoding #13444
-
Hi all! I'm using the micropython captive portal made by metachris (https://github.com/metachris/micropython-captiveportal) to have the user connect to the ESP32 and provide credentials for their WiFi network. It's a bit out of my depth, but I fumbled through some edits to extract the inputs from an HTML form I made, as such: Note that I simply noticed the format of the incoming GET request with the form data and parsed the field information from this string. I'm having one problem here though, which is that symbols are being encoded as unicode in the convention of "%xx" where xx is the unicode ID. I was starting to write a manual regex method to conduct substitutions, but was wondering if there's a better way of doing this. I want to avoid the manual route if there's something comprehensive, because I will inevitably omit some character(s) and then funky passwords or SSID's will be non-functional. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Its not unicode encoding, its |
Beta Was this translation helpful? Give feedback.
-
The best thing to do is to replace with javascript unicode char before posting html ... |
Beta Was this translation helpful? Give feedback.
Its not unicode encoding, its
application/x-www-form-urlencoded
url encoding. On python, you usually decode that withurllib.parse.unquote()
, which I believe is not supported by micropython on most ports. There is a compact solution forunquote()
available on the old forum https://forum.micropython.org/viewtopic.php?t=3076. See the last message on that page.