Merge branch 'master' into smartcard-relay

This commit is contained in:
Grayson Martin 2023-11-11 13:05:11 -06:00
commit 4e346e8ca2
No known key found for this signature in database
GPG key ID: 4914C62F2696A273
159 changed files with 10035 additions and 2880 deletions

View file

@ -147,6 +147,7 @@ enum ParserState {
PS_FIRST,
PS_ARGUMENT,
PS_OPTION,
PS_QUOTE,
};
#define isSpace(c)(c == ' ' || c == '\t')
@ -195,6 +196,10 @@ int CLIParserParseStringEx(CLIParserContext *ctx, const char *str, void *vargtab
case PS_ARGUMENT:
if (state == PS_FIRST)
state = PS_ARGUMENT;
if (str[i] == '"') {
state = PS_QUOTE;
break;
}
if (isSpace(str[i])) {
spaceptr = bufptr;
state = PS_FIRST;
@ -215,6 +220,16 @@ int CLIParserParseStringEx(CLIParserContext *ctx, const char *str, void *vargtab
*bufptr = str[i];
bufptr++;
break;
case PS_QUOTE:
if (str[i] == '"') {
*bufptr++ = 0x00;
state = PS_FIRST;
} else {
if (isSpace(str[i]) == false) {
*bufptr++ = str[i];
}
}
break;
}
if (bufptr > bufptrend) {
PrintAndLogEx(ERR, "ERROR: Line too long\n");