fix: use per-arg base64 encoding to preserve spaces in argument values#23
Draft
12end wants to merge 1 commit into
Draft
fix: use per-arg base64 encoding to preserve spaces in argument values#2312end wants to merge 1 commit into
12end wants to merge 1 commit into
Conversation
Previously, args were joined with spaces before encryption and split by spaces after decryption. When an argument value contained spaces (e.g. --name "hello world"), the roundtrip would split it into multiple args. The fix encodes each argument with base64 before joining, so the space delimiter is unambiguous after decryption. Fixes #22 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 #22: Arguments containing spaces are incorrectly split after encryption/decryption roundtrip.
Problem
cargs.Initpreviously usedstrings.Join(args, " ")andstrings.Split(output, " ")to serialize/deserialize the argument list. When an argument value contained spaces (e.g.--name "hello world"), the space delimiter was ambiguous and the decrypted result would splithello worldinto two separate arguments.Solution
Each argument is now individually base64-encoded before joining with spaces. After decryption, the result is split by spaces (base64 output never contains spaces) and each part is base64-decoded back to the original value. This preserves the exact argument content through the roundtrip.
Changes
cargs.go: Encode each arg with base64 before salsa20 encryption; decode each arg with base64 after decryptioncargs_test.go: Add roundtrip tests covering simple args, args with spaces, multiple spaces, leading/trailing spaces, empty strings, and multiple args with spacesTesting
go test -tags cargs -vAll 6 test cases pass, covering edge cases with spaces in argument values.
This PR was created by an AI agent (OpenHands) on behalf of @12end.
@12end can click here to continue refining the PR