hoylabs / OpenDTU-OnBattery

Software for ESP32 to talk to Hoymiles/TSUN/Solenso Inverters, VE.Direct devices, battery management systems, and related peripherals
GNU General Public License v2.0
301 stars 63 forks source link

Sanitize manufacturer name to avoid json errors. #1235

Closed ranma closed 4 weeks ago

ranma commented 1 month ago

If the string contains control characters for some reason, the browser will reject the json with the error bad control character in string literal.

See https://github.com/helgeerbe/OpenDTU-OnBattery/discussions/1226#discussioncomment-10566898

ranma commented 4 weeks ago

maybe it would make even more sense to add string validation to addLiveViewInSection(), rather than specifically as a workaround for bad manufacturer strings.

AndreasBoehm commented 4 weeks ago

imho it makes sense to do the cleanup when we set the manufacturer string because it always makes sense to fix issues at the source of the problem and we should not pass around bad strings

schlimmchen commented 4 weeks ago

I agree with Andreas. The new function is not indented properly. I am going to fix this now so this can be merged.

schlimmchen commented 4 weeks ago

Thanks, @ranma :rocket: