Fix: preserve spaces in argument values through encrypt/decrypt cycle#21
Draft
12end wants to merge 1 commit into
Draft
Fix: preserve spaces in argument values through encrypt/decrypt cycle#2112end wants to merge 1 commit into
12end wants to merge 1 commit into
Conversation
Previously, cargs.Init used strings.Join/Split with space as delimiter, which broke arguments containing spaces (e.g. '--name "hello world"' would become '--name', 'hello', 'world' after encrypt/decrypt). Now each argument is individually base64-encoded, then joined with newline - a character never produced by base64 encoding. On decrypt, arguments are split by newline and individually decoded. Fixes #19 Co-authored-by: openhands <openhands@all-hands.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #19: Arguments containing spaces were incorrectly split after the encrypt/decrypt cycle in
cargs.Init.Problem
cargs.Initusedstrings.Join(args, " ")andstrings.Split(output, " ")to serialize/deserialize arguments. Since space was used as both a delimiter and a valid character in argument values, arguments like--name "hello world"would become["--name", "hello", "world"]after decryption instead of["--name", "hello world"].Solution
Each argument is now individually base64-encoded before being joined with a newline character (
\n) — which is never produced by base64 encoding. On decryption, arguments are split by newline and individually base64-decoded. This preserves the exact argument boundaries and content through the round-trip.Changes
cargs.go: Replacedstrings.Join/strings.Splitwith per-argument base64 encoding using newline as delimitercargs_test.go: Added tests verifying arguments with spaces and consecutive spaces survive the round-triptestdata/helper/main.go: Test helper binary used for integration testing of the full encrypt/decrypt cycleVerification
This PR was created by an AI agent (OpenHands) on behalf of @12end.
@12end can click here to continue refining the PR