mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 20:46:52 +03:00
Support white space and equal in passwords (#1327)
* Updated the web Installer page, removed all redudnant files in the docs folder, updated the main README * . * consolidate the 2 identical ZerlegeZeile() function and move it to Helper.cpp and add workaround for whitespace and equal sign in password fields * remove redundant code in HelperZerlegeZeile() * Updated the web Installer page, removed all redudnant files in the docs folder, updated the main README * . * consolidate the 2 identical ZerlegeZeile() function and move it to Helper.cpp and add workaround for whitespace and equal sign in password fields * remove redundant code in HelperZerlegeZeile()
This commit is contained in:
@@ -82,25 +82,3 @@ bool ConfigFile::getNextLine(std::string *rt, bool &disabled, bool &eof)
|
|||||||
disabled = ((*rt)[0] == ';');
|
disabled = ((*rt)[0] == ';');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<string> ConfigFile::ZerlegeZeile(std::string input, std::string delimiter)
|
|
||||||
{
|
|
||||||
std::vector<string> Output;
|
|
||||||
// std::string delimiter = " =,";
|
|
||||||
|
|
||||||
input = trim(input, delimiter);
|
|
||||||
size_t pos = findDelimiterPos(input, delimiter);
|
|
||||||
std::string token;
|
|
||||||
while (pos != std::string::npos) {
|
|
||||||
token = input.substr(0, pos);
|
|
||||||
token = trim(token, delimiter);
|
|
||||||
Output.push_back(token);
|
|
||||||
input.erase(0, pos + 1);
|
|
||||||
input = trim(input, delimiter);
|
|
||||||
pos = findDelimiterPos(input, delimiter);
|
|
||||||
}
|
|
||||||
Output.push_back(input);
|
|
||||||
|
|
||||||
return Output;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ public:
|
|||||||
bool isNewParagraph(std::string input);
|
bool isNewParagraph(std::string input);
|
||||||
bool GetNextParagraph(std::string& aktparamgraph, bool &disabled, bool &eof);
|
bool GetNextParagraph(std::string& aktparamgraph, bool &disabled, bool &eof);
|
||||||
bool getNextLine(std::string* rt, bool &disabled, bool &eof);
|
bool getNextLine(std::string* rt, bool &disabled, bool &eof);
|
||||||
std::vector<std::string> ZerlegeZeile(std::string input, std::string delimiter = " =, \t");
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ bool GpioHandler::readConfig()
|
|||||||
bool registerISR = false;
|
bool registerISR = false;
|
||||||
while (configFile.getNextLine(&line, disabledLine, eof) && !configFile.isNewParagraph(line))
|
while (configFile.getNextLine(&line, disabledLine, eof) && !configFile.isNewParagraph(line))
|
||||||
{
|
{
|
||||||
zerlegt = configFile.ZerlegeZeile(line);
|
zerlegt = ZerlegeZeile(line);
|
||||||
// const std::regex pieces_regex("IO([0-9]{1,2})");
|
// const std::regex pieces_regex("IO([0-9]{1,2})");
|
||||||
// std::smatch pieces_match;
|
// std::smatch pieces_match;
|
||||||
// if (std::regex_match(zerlegt[0], pieces_match, pieces_regex) && (pieces_match.size() == 2))
|
// if (std::regex_match(zerlegt[0], pieces_match, pieces_regex) && (pieces_match.size() == 2))
|
||||||
|
|||||||
@@ -15,30 +15,6 @@ void ClassFlow::SetInitialParameter(void)
|
|||||||
disabled = false;
|
disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<string> ClassFlow::ZerlegeZeile(std::string input, std::string delimiter)
|
|
||||||
{
|
|
||||||
std::vector<string> Output;
|
|
||||||
|
|
||||||
input = trim(input, delimiter);
|
|
||||||
size_t pos = findDelimiterPos(input, delimiter);
|
|
||||||
std::string token;
|
|
||||||
while (pos != std::string::npos) {
|
|
||||||
token = input.substr(0, pos);
|
|
||||||
token = trim(token, delimiter);
|
|
||||||
Output.push_back(token);
|
|
||||||
input.erase(0, pos + 1);
|
|
||||||
input = trim(input, delimiter);
|
|
||||||
pos = findDelimiterPos(input, delimiter);
|
|
||||||
}
|
|
||||||
Output.push_back(input);
|
|
||||||
|
|
||||||
return Output;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ClassFlow::isNewParagraph(string input)
|
bool ClassFlow::isNewParagraph(string input)
|
||||||
{
|
{
|
||||||
if ((input[0] == '[') || ((input[0] == ';') && (input[1] == '[')))
|
if ((input[0] == '[') || ((input[0] == ';') && (input[1] == '[')))
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ struct HTMLInfo
|
|||||||
class ClassFlow
|
class ClassFlow
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::vector<string> ZerlegeZeile(string input, string delimiter = " =, \t");
|
|
||||||
bool isNewParagraph(string input);
|
bool isNewParagraph(string input);
|
||||||
bool GetNextParagraph(FILE* pfile, string& aktparamgraph);
|
bool GetNextParagraph(FILE* pfile, string& aktparamgraph);
|
||||||
bool getNextLine(FILE* pfile, string* rt);
|
bool getNextLine(FILE* pfile, string* rt);
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = ZerlegeZeile(aktparamgraph);
|
||||||
if ((toUpper(zerlegt[0]) == "LOGIMAGELOCATION") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "LOGIMAGELOCATION") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
this->LogImageLocation = "/sdcard" + zerlegt[1];
|
this->LogImageLocation = "/sdcard" + zerlegt[1];
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph, " =");
|
zerlegt = ZerlegeZeile(aktparamgraph, " =");
|
||||||
if ((toUpper(zerlegt[0]) == "AUTOSTART") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "AUTOSTART") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
if (toUpper(zerlegt[1]) == "TRUE")
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ bool ClassFlowInfluxDB::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "while loop reading line: %s", aktparamgraph.c_str());
|
ESP_LOGD(TAG, "while loop reading line: %s", aktparamgraph.c_str());
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = ZerlegeZeile(aktparamgraph);
|
||||||
if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
this->user = zerlegt[1];
|
this->user = zerlegt[1];
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = ZerlegeZeile(aktparamgraph);
|
||||||
if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
this->user = zerlegt[1];
|
this->user = zerlegt[1];
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = ZerlegeZeile(aktparamgraph);
|
||||||
if ((zerlegt[0] == "LogImageLocation") && (zerlegt.size() > 1))
|
if ((zerlegt[0] == "LogImageLocation") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
LogImageLocation = "/sdcard" + zerlegt[1];
|
LogImageLocation = "/sdcard" + zerlegt[1];
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = ZerlegeZeile(aktparamgraph);
|
||||||
std::string _param = GetParameterName(zerlegt[0]);
|
std::string _param = GetParameterName(zerlegt[0]);
|
||||||
|
|
||||||
if ((toUpper(_param) == "EXTENDEDRESOLUTION") && (zerlegt.size() > 1))
|
if ((toUpper(_param) == "EXTENDEDRESOLUTION") && (zerlegt.size() > 1))
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ bool ClassFlowWriteList::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = ZerlegeZeile(aktparamgraph);
|
||||||
/*
|
/*
|
||||||
if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -541,7 +541,37 @@ std::vector<string> HelperZerlegeZeile(std::string input, std::string _delimiter
|
|||||||
delimiter = _delimiter;
|
delimiter = _delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ZerlegeZeile(input, delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<string> ZerlegeZeile(std::string input, std::string delimiter)
|
||||||
|
{
|
||||||
|
std::vector<string> Output;
|
||||||
|
|
||||||
input = trim(input, delimiter);
|
input = trim(input, delimiter);
|
||||||
|
|
||||||
|
/* The input can have multiple formats:
|
||||||
|
* - key = value
|
||||||
|
* - key = value1 value2 value3 ...
|
||||||
|
* - key value1 value2 value3 ...
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* - ImageSize = VGA
|
||||||
|
* - IO0 = input disabled 10 false false
|
||||||
|
* - main.dig1 28 144 55 100 false
|
||||||
|
*
|
||||||
|
* This causes issues eg. if a password key has a whitespace or equal sign in its value.
|
||||||
|
* As a workaround and to not break any legacy usage, we enforce to only use the
|
||||||
|
* equal sign, if the key is "password"
|
||||||
|
*/
|
||||||
|
if (input.find("password") != string::npos) { // Line contains a password, use the equal sign as the only delimiter and only split on first occurrence
|
||||||
|
size_t pos = input.find("=");
|
||||||
|
Output.push_back(trim(input.substr(0, pos), ""));
|
||||||
|
Output.push_back(trim(input.substr(pos +1, string::npos), ""));
|
||||||
|
}
|
||||||
|
else { // Legacy Mode
|
||||||
size_t pos = findDelimiterPos(input, delimiter);
|
size_t pos = findDelimiterPos(input, delimiter);
|
||||||
std::string token;
|
std::string token;
|
||||||
while (pos != std::string::npos) {
|
while (pos != std::string::npos) {
|
||||||
@@ -553,8 +583,10 @@ std::vector<string> HelperZerlegeZeile(std::string input, std::string _delimiter
|
|||||||
pos = findDelimiterPos(input, delimiter);
|
pos = findDelimiterPos(input, delimiter);
|
||||||
}
|
}
|
||||||
Output.push_back(input);
|
Output.push_back(input);
|
||||||
|
}
|
||||||
|
|
||||||
return Output;
|
return Output;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ time_t addDays(time_t startTime, int days);
|
|||||||
void memCopyGen(uint8_t* _source, uint8_t* _target, int _size);
|
void memCopyGen(uint8_t* _source, uint8_t* _target, int _size);
|
||||||
|
|
||||||
std::vector<string> HelperZerlegeZeile(std::string input, std::string _delimiter);
|
std::vector<string> HelperZerlegeZeile(std::string input, std::string _delimiter);
|
||||||
|
std::vector<std::string> ZerlegeZeile(std::string input, std::string delimiter = " =, \t");
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
size_t getInternalESPHeapSize();
|
size_t getInternalESPHeapSize();
|
||||||
|
|||||||
@@ -50,6 +50,28 @@ function ZerlegeZeile(input, delimiter = " =\t\r")
|
|||||||
// delimiter = " =,\t";
|
// delimiter = " =,\t";
|
||||||
|
|
||||||
input = trim(input, delimiter);
|
input = trim(input, delimiter);
|
||||||
|
|
||||||
|
/* The input can have multiple formats:
|
||||||
|
* - key = value
|
||||||
|
* - key = value1 value2 value3 ...
|
||||||
|
* - key value1 value2 value3 ...
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* - ImageSize = VGA
|
||||||
|
* - IO0 = input disabled 10 false false
|
||||||
|
* - main.dig1 28 144 55 100 false
|
||||||
|
*
|
||||||
|
* This causes issues eg. if a password key has a whitespace or equal sign in its value.
|
||||||
|
* As a workaround and to not break any legacy usage, we enforce to only use the
|
||||||
|
* equal sign, if the key is "password"
|
||||||
|
*/
|
||||||
|
if (input.includes("password")) { // Line contains a password, use the equal sign as the only delimiter and only split on first occurrence
|
||||||
|
console.log(input);
|
||||||
|
var pos = input.indexOf("=");
|
||||||
|
Output.push(trim(input.substr(0, pos), delimiter));
|
||||||
|
Output.push(trim(input.substr(pos +1, input.length), delimiter));
|
||||||
|
}
|
||||||
|
else { // Legacy Mode
|
||||||
var pos = findDelimiterPos(input, delimiter);
|
var pos = findDelimiterPos(input, delimiter);
|
||||||
var token;
|
var token;
|
||||||
while (pos > -1) {
|
while (pos > -1) {
|
||||||
@@ -61,6 +83,7 @@ function ZerlegeZeile(input, delimiter = " =\t\r")
|
|||||||
pos = findDelimiterPos(input, delimiter);
|
pos = findDelimiterPos(input, delimiter);
|
||||||
}
|
}
|
||||||
Output.push(input);
|
Output.push(input);
|
||||||
|
}
|
||||||
|
|
||||||
return Output;
|
return Output;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user