mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 03:56:57 +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:
@@ -541,20 +541,52 @@ std::vector<string> HelperZerlegeZeile(std::string input, std::string _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);
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
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);
|
||||
}
|
||||
Output.push_back(input);
|
||||
|
||||
return Output;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user