PowerShell single-quoted words are literal; an apostrophe is represented by * two apostrophes. This prevents $env expansion and command substitution. */
| 4888 | /* PowerShell single-quoted words are literal; an apostrophe is represented by |
| 4889 | * two apostrophes. This prevents $env expansion and command substitution. */ |
| 4890 | static int cbm_powershell_quote_word(const char *value, char *out, size_t out_size) { |
| 4891 | if (!value || !out || out_size < CLI_PAIR_LEN) { |
| 4892 | return CLI_ERR; |
| 4893 | } |
| 4894 | size_t used = 0U; |
| 4895 | out[used++] = '\''; |
| 4896 | for (const unsigned char *cursor = (const unsigned char *)value; *cursor; cursor++) { |
| 4897 | if (*cursor < 0x20U || *cursor == 0x7fU) { |
| 4898 | out[0] = '\0'; |
| 4899 | return CLI_ERR; |
| 4900 | } |
| 4901 | size_t needed = *cursor == '\'' ? 2U : 1U; |
| 4902 | if (needed > out_size - used - CLI_PAIR_LEN) { |
| 4903 | out[0] = '\0'; |
| 4904 | return CLI_ERR; |
| 4905 | } |
| 4906 | out[used++] = (char)*cursor; |
| 4907 | if (*cursor == '\'') { |
| 4908 | out[used++] = '\''; |
| 4909 | } |
| 4910 | } |
| 4911 | if (used >= out_size - CLI_SKIP_ONE) { |
| 4912 | out[0] = '\0'; |
| 4913 | return CLI_ERR; |
| 4914 | } |
| 4915 | out[used++] = '\''; |
| 4916 | out[used] = '\0'; |
| 4917 | return CLI_OK; |
| 4918 | } |
| 4919 | |
| 4920 | static bool cbm_write_owned_hook_script_with_legacy(const char *path, const char *script, |
| 4921 | const char *const *legacy_scripts, |
no outgoing calls
no test coverage detected