PowerShell single-quoted words are literal; an apostrophe is represented by * two apostrophes. This prevents $env expansion and command substitution. */
| 5352 | /* PowerShell single-quoted words are literal; an apostrophe is represented by |
| 5353 | * two apostrophes. This prevents $env expansion and command substitution. */ |
| 5354 | static int cbm_powershell_quote_word(const char *value, char *out, size_t out_size) { |
| 5355 | if (!value || !out || out_size < CLI_PAIR_LEN) { |
| 5356 | return CLI_ERR; |
| 5357 | } |
| 5358 | size_t used = 0U; |
| 5359 | out[used++] = '\''; |
| 5360 | for (const unsigned char *cursor = (const unsigned char *)value; *cursor; cursor++) { |
| 5361 | if (*cursor < 0x20U || *cursor == 0x7fU) { |
| 5362 | out[0] = '\0'; |
| 5363 | return CLI_ERR; |
| 5364 | } |
| 5365 | size_t needed = *cursor == '\'' ? 2U : 1U; |
| 5366 | if (needed > out_size - used - CLI_PAIR_LEN) { |
| 5367 | out[0] = '\0'; |
| 5368 | return CLI_ERR; |
| 5369 | } |
| 5370 | out[used++] = (char)*cursor; |
| 5371 | if (*cursor == '\'') { |
| 5372 | out[used++] = '\''; |
| 5373 | } |
| 5374 | } |
| 5375 | if (used >= out_size - CLI_SKIP_ONE) { |
| 5376 | out[0] = '\0'; |
| 5377 | return CLI_ERR; |
| 5378 | } |
| 5379 | out[used++] = '\''; |
| 5380 | out[used] = '\0'; |
| 5381 | return CLI_OK; |
| 5382 | } |
| 5383 | |
| 5384 | static bool cbm_write_owned_hook_script_with_legacy(const char *path, const char *script, |
| 5385 | const char *const *legacy_scripts, |
no outgoing calls
no test coverage detected