mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 00:04:28 +01:00
[GH-ISSUE #429] Empty value in json template variable will crash AP #3571
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghoeffner on GitHub (Jan 14, 2025).
Original GitHub issue: https://github.com/OpenEPaperLink/OpenEPaperLink/issues/429
Originally assigned to: @nlimper on GitHub.
Describe the bug
This caused me a log of headache and I even reset the whole AP (and accidently lost my json templates), until I figured out what is actually going on. Seems like a empty value on the second level of a json returned in the fetch URL of a json template tag will straight out crash the AP.
To Reproduce
Tested on the following tag:
M2 2.6"
296x152 fw:40 0x28
json template
data returned on URL:
{ "test1": { "test": "" } }Now fill in any string in the "test" value and you will see that it recovers from crashing and returns to expected behavior.
Expected behavior
It should not crash ;-)
@ghoeffner commented on GitHub (Apr 18, 2025):
Issue present on latest build.
@nlimper commented on GitHub (Apr 18, 2025):
If you want to try to fix it: it's somewhere in this part of the code:
https://github.com/OpenEPaperLink/OpenEPaperLink/blob/master/ESP32_AP-Flasher/src/contentmanager.cpp#L2114-L2257
Probably in the
extractValueFromJsonfunction, or in thefindAndReplacefunction that uses extractValueFromJson.@NickWaterton commented on GitHub (Jan 24, 2026):
I just ran into this today - still present in the latest build.
Took me about 2 hours to figure out what the problem was. There are no error messages or anything - just a silent crash + reboot.
Doesn't have to be a variable, if you just send something like a Text line with an empty string in a template - crash.
Also, doesn't have to be an empty string, a string consisting of just white space does the same, so
" "crashes just the same as"".I believe the problem is in:
If you pass this a
NULLstring (ie'\0') I don't think the behavior offormat.indexOf('{', startIndex))is defined.I think a simple fix would be to just early return if the string length is 0. I can't test this, as I don't have a build environment.
Can anyone try this? it's 100% repeatable, so should be easy to test.
@NickWaterton commented on GitHub (Feb 6, 2026):
UPDATE:
For anyone else that runs into this, I have found the problem, its in
drawString(), notreplaceVariables()as I thought.Made a build environment, and tested out the fix, this is it:
It's pretty simple, just add a check for a NULL string at the top:
This will then skip drawing the text if it's empty, the same as displaying
"". Prevents the stack corruption reboot that you get otherwise.My fork with the fix is here https://github.com/NickWaterton/OpenEPaperLink/tree/master
But be warned, it has a lot of changes in it, along with replacing the old Bluedroid BLE library with NimBLE, which makes it a lot more reliable - ie it doesn't crash evey hour or so.