mirror of https://github.com/libsdl-org/SDL
Windows process: escape backslashes before quotes
This commit is contained in:
parent
90e01040c5
commit
3cf54675bb
|
@ -95,6 +95,10 @@ static bool join_arguments(const char * const *args, char **args_out)
|
||||||
case '"':
|
case '"':
|
||||||
len += 2;
|
len += 2;
|
||||||
break;
|
break;
|
||||||
|
case '\\':
|
||||||
|
/* only escape backslashes that precede a double quote */
|
||||||
|
len += (*(a + 1) == '"' || *(a + 1) == '\0') ? 2 : 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
len += 1;
|
len += 1;
|
||||||
break;
|
break;
|
||||||
|
@ -121,6 +125,12 @@ static bool join_arguments(const char * const *args, char **args_out)
|
||||||
result[i_out++] = '\\';
|
result[i_out++] = '\\';
|
||||||
result[i_out++] = *a;
|
result[i_out++] = *a;
|
||||||
break;
|
break;
|
||||||
|
case '\\':
|
||||||
|
result[i_out++] = *a;
|
||||||
|
if (*(a + 1) == '"' || *(a + 1) == '\0') {
|
||||||
|
result[i_out++] = *a;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
result[i_out++] = *a;
|
result[i_out++] = *a;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -92,6 +92,9 @@ static int SDLCALL process_testArguments(void *arg)
|
||||||
"'a' 'b' 'c'",
|
"'a' 'b' 'c'",
|
||||||
"%d%%%s",
|
"%d%%%s",
|
||||||
"\\t\\c",
|
"\\t\\c",
|
||||||
|
"evil\\",
|
||||||
|
"a\\b\"c\\",
|
||||||
|
"\"\\^&|<>%", /* characters with a special meaning */
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
SDL_Process *process = NULL;
|
SDL_Process *process = NULL;
|
||||||
|
|
Loading…
Reference in New Issue