PowerShell single-quoted words are literal; an apostrophe is represented by * two apostrophes. This prevents $env expansion and command substitution. */
| 5484 | /* PowerShell single-quoted words are literal; an apostrophe is represented by |
| 5485 | * two apostrophes. This prevents $env expansion and command substitution. */ |
| 5486 | static int cbm_powershell_quote_word(const char *value, char *out, size_t out_size) { |
| 5487 | if (!value || !out || out_size < CLI_PAIR_LEN) { |
| 5488 | return CLI_ERR; |
| 5489 | } |
| 5490 | size_t used = 0U; |
| 5491 | out[used++] = '\''; |
| 5492 | for (const unsigned char *cursor = (const unsigned char *)value; *cursor; cursor++) { |
| 5493 | if (*cursor < 0x20U || *cursor == 0x7fU) { |
| 5494 | out[0] = '\0'; |
| 5495 | return CLI_ERR; |
| 5496 | } |
| 5497 | size_t needed = *cursor == '\'' ? 2U : 1U; |
| 5498 | if (needed > out_size - used - CLI_PAIR_LEN) { |
| 5499 | out[0] = '\0'; |
| 5500 | return CLI_ERR; |
| 5501 | } |
| 5502 | out[used++] = (char)*cursor; |
| 5503 | if (*cursor == '\'') { |
| 5504 | out[used++] = '\''; |
| 5505 | } |
| 5506 | } |
| 5507 | if (used >= out_size - CLI_SKIP_ONE) { |
| 5508 | out[0] = '\0'; |
| 5509 | return CLI_ERR; |
| 5510 | } |
| 5511 | out[used++] = '\''; |
| 5512 | out[used] = '\0'; |
| 5513 | return CLI_OK; |
| 5514 | } |
| 5515 | |
| 5516 | static bool cbm_write_owned_hook_script_with_legacy(const char *path, const char *script, |
| 5517 | const char *const *legacy_scripts, |
no outgoing calls
no test coverage detected