Juerd / ESP-WiFiSettings

WiFi Manager for the ESP32 Arduino environment
Other
166 stars 34 forks source link

Handle unicode characters correctly #14

Closed Kreisverkehr closed 3 years ago

Kreisverkehr commented 3 years ago

I just noticed that unicode characters that are more than one byte long aren't properly displayed in the portal. After investigating the issue i found tha all characters are converted to single byte characters in the html_entities method. The call to Sprintf seems unneccesary to me and everything works fine so far. Please note that I've only tested this on the ESP8266. I do not have an esp32 to test with.

I also corrected a mistake in the buildflags for the german language and made the html well formed.

Juerd commented 3 years ago

Thanks, but I can't accept this PR because strings need to be escaped in HTML, because some characters have specific meanings, like <. The function html_entities is a lazy (and indeed not unicode aware) way to implement that. I agree that it's broken, but this fix breaks other things, as it turns html_entities into just an elaborate string copier :). I think the right way would be to keep bytes >= 0x80 unencoded.

Furthermore, contrary to popular belief, the tags html and body are optional in HTML. Because of Flash and RAM usage, I prefer to leave out anything that isn't strictly necessary. https://dev.w3.org/html5/spec-LC/syntax.html#optional-tags

Kreisverkehr commented 3 years ago

Thank you for the feedback. I did not know that the html, headand bodytags were optional in most cases. I agree with you that it makes sense to leave them out.

I would try to make the html_entities function unicode aware and open another PR if that's ok?

Juerd commented 3 years ago

Sure! Please do so in a fresh clone or branch, without the commits from this PR.