1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

common,w32: Refine the command line parsing for \ in quotes.

* common/t-w32-cmdline.c (test_all): Add new test cases.
* common/w32-misc.c (strip_one_arg): Add arg endquote.
(parse_cmdstring): Take care of backslashes in quotes.
--

I found some new test vectors from Microsoft.

(cherry picked from commit 20c6007686)
This commit is contained in:
Werner Koch 2021-03-04 12:30:30 +01:00
parent 90ddd1cf13
commit 4d6807b215
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
2 changed files with 33 additions and 6 deletions

View file

@ -59,8 +59,18 @@ test_all (void)
{ "a\\\\\\b d\"e f\"g h", 3, { "a\\\\\\b", "de fg", "h" }},
{ "a\\\\\\\"b c d", 3, { "a\\\"b", "c", "d" }},
{ "a\\\\\\\\\"b c\" d e", 3, { "a\\\\b c", "d", "e" }},
/* Examples from "Parsing C Command-Line Arguments" dated 11/09/2020.
* https://docs.microsoft.com/en-us/cpp/c-language/\
* parsing-c-command-line-arguments?view=msvc-160
*/
{ "\"a b c\" d e", 3, { "a b c", "d", "e" }},
{ "\"ab\\\"c\" \"\\\\\" d", 3, { "ab\"c", "\\", "d" }},
{ "a\\\\\\b d\"e f\"g h", 3, { "a\\\\\\b", "de fg", "h" }},
{ "a\\\\\\\"b c d", 3, { "a\\\"b", "c", "d" }},
{ "a\\\\\\\\\"b c\" d e", 3, { "a\\\\b c", "d", "e" }},
{ "a\"b\"\" c d", 1, { "ab\" c d" }},
/* Some arbitrary tests created using mingw.
* But I am nire sure whether their parser is fully correct.
* But I am not sure whether their parser is fully correct.
*/
{ "e:a a b\"c\" ", 3, { "e:a", "a", "bc" }},
/* { "e:a a b\"c\"\" d\"\"e \" ", */