unicode-related robustness improvements
* enable ARDUINOJSON_DECODE_UNICODE (otherwise unicode needs 6(!) bytes for encoding) * robustness: increase a few tiny string buffers for some extra margin * Web UI: allow entering up to 64 chars as segment name
This commit is contained in:
@@ -827,7 +827,7 @@ function populateSegments(s)
|
||||
(cfg.comp.segpwr ? segp : '') +
|
||||
`<div class="segin" id="seg${i}in">`+
|
||||
`<input id="seg${i}fx" value="${inst.fx}" type="hidden"/>` + // <!--WLEDMM-->
|
||||
`<input type="text" class="ptxt" id="seg${i}t" autocomplete="off" maxlength=32 value="${inst.n?inst.n:""}" placeholder="Enter name..."/>`+
|
||||
`<input type="text" class="ptxt" id="seg${i}t" autocomplete="off" maxlength=64 value="${inst.n?inst.n:""}" placeholder="Enter name..."/>`+
|
||||
`<table class="infot segt">`+
|
||||
`<tr>`+
|
||||
`<td>${isMSeg?'Start X':'Start LED'}</td>`+
|
||||
|
||||
@@ -214,7 +214,7 @@ bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint
|
||||
if (!f) return false;
|
||||
|
||||
if (f.size() < 3) {
|
||||
char init[10];
|
||||
char init[12];
|
||||
strcpy_P(init, PSTR("{\"0\":{}}"));
|
||||
f.print(init);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint
|
||||
|
||||
bool writeObjectToFileUsingId(const char* file, uint16_t id, JsonDocument* content)
|
||||
{
|
||||
char objKey[10];
|
||||
char objKey[12];
|
||||
sprintf(objKey, "\"%d\":", id);
|
||||
return writeObjectToFile(file, objKey, content);
|
||||
}
|
||||
@@ -360,7 +360,7 @@ bool writeObjectToFile(const char* file, const char* key, JsonDocument* content)
|
||||
|
||||
bool readObjectFromFileUsingId(const char* file, uint16_t id, JsonDocument* dest)
|
||||
{
|
||||
char objKey[10];
|
||||
char objKey[12];
|
||||
sprintf(objKey, "\"%d\":", id);
|
||||
return readObjectFromFile(file, objKey, dest);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ static volatile byte presetToApply = 0;
|
||||
static volatile byte callModeToApply = 0;
|
||||
static volatile byte presetToSave = 0;
|
||||
static volatile int8_t saveLedmap = -1;
|
||||
static char quickLoad[9];
|
||||
static char quickLoad[12]; // WLEDMM 9->12 to prevent crashing with unicode
|
||||
static char saveName[33];
|
||||
static bool includeBri = true, segBounds = true, selectedOnly = false, playlistSave = false;
|
||||
|
||||
@@ -88,8 +88,8 @@ static void doSaveState() {
|
||||
// clean up
|
||||
saveLedmap = -1;
|
||||
presetToSave = 0;
|
||||
saveName[0] = '\0';
|
||||
quickLoad[0] = '\0';
|
||||
memset(saveName, '\0', sizeof(saveName));
|
||||
memset(quickLoad,'\0', sizeof(quickLoad));
|
||||
playlistSave = false;
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ void savePreset(byte index, const char* pname, JsonObject sObj)
|
||||
|
||||
presetToSave = index;
|
||||
playlistSave = false;
|
||||
if (sObj[F("ql")].is<const char*>()) strlcpy(quickLoad, sObj[F("ql")].as<const char*>(), 9); // client limits QL to 2 chars, buffer for 8 bytes to allow unicode
|
||||
if (sObj[F("ql")].is<const char*>()) strlcpy(quickLoad, sObj[F("ql")].as<const char*>(), sizeof(quickLoad)); // client limits QL to 2 chars, buffer for 12 bytes to allow encoded unicode
|
||||
|
||||
if (sObj.size()==0 || sObj["o"].isNull()) { // no "o" means not a playlist or custom API call, saving of state is async (not immediately)
|
||||
includeBri = sObj["ib"].as<bool>() || sObj.size()==0 || index==255; // temporary preset needs brightness
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
#include "src/dependencies/async-mqtt-client/AsyncMqttClient.h"
|
||||
#endif
|
||||
|
||||
#define ARDUINOJSON_DECODE_UNICODE 0
|
||||
#define ARDUINOJSON_DECODE_UNICODE 1 // WLEDMM enable unicode support -> prevents crashes when user enters unicode strings in webUI
|
||||
#include "src/dependencies/json/AsyncJson-v6.h"
|
||||
#include "src/dependencies/json/ArduinoJson-v6.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user