diff options
| author | akbash <akbash@herdr.dev> | 2026-08-30 03:03:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-30 03:03:25 +0300 |
| commit | 4a3b04f59ba3b7d8a15cea187b23e1e80c343b0c (patch) | |
| tree | e1a38be588e702c39c434092f8b7a7a218e88f7c /src/integration/command.rs | |
| parent | 3a3792622e59c7f2dc20f9c0236167161e4a5035 (diff) | |
fix: encode antigravity windows hook command (#3352)
refs #3348
Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src/integration/command.rs')
| -rw-r--r-- | src/integration/command.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/integration/command.rs b/src/integration/command.rs index a5d58f0c..144fab4a 100644 --- a/src/integration/command.rs +++ b/src/integration/command.rs @@ -1,5 +1,8 @@ use std::path::Path; +#[cfg(any(windows, test))] +use base64::Engine; + pub(crate) fn shell_single_quote(value: &str) -> String { format!("'{}'", value.replace('\'', "'\"'\"'")) } @@ -30,6 +33,18 @@ pub(crate) fn hook_command(hook_path: &Path, action: Option<&str>) -> String { } } +#[cfg(any(windows, test))] +pub(crate) fn powershell_encoded_hook_command(hook_path: &Path, action: &str) -> String { + let path = hook_path.display().to_string().replace('\'', "''"); + let script = format!("& '{path}' {action}"); + let encoded_script = script + .encode_utf16() + .flat_map(u16::to_le_bytes) + .collect::<Vec<_>>(); + let encoded = base64::engine::general_purpose::STANDARD.encode(encoded_script); + format!("powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand {encoded}") +} + pub(crate) fn legacy_bash_hook_command(hook_path: &Path, action: Option<&str>) -> String { let mut command = format!( "bash {}", |
