diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bc571b5a..6a711b51c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] + - Add support for quoted arguments in the CLI, allowing spaces in them which + are removed automatically (@jmichelp) - Added UDP support on Windows (@wh201906) - Added client communication timeout to preferences (@iceman1001) - Added IPv6 support (@wh201906) diff --git a/client/deps/cliparser/cliparser.c b/client/deps/cliparser/cliparser.c index e5e8f946c..0ea0bd33b 100644 --- a/client/deps/cliparser/cliparser.c +++ b/client/deps/cliparser/cliparser.c @@ -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");