Skip to content

fix: use per-arg base64 encoding to preserve spaces in argument values#23

Draft
12end wants to merge 1 commit into
masterfrom
openhands/fix-issue-22-args-spaces
Draft

fix: use per-arg base64 encoding to preserve spaces in argument values#23
12end wants to merge 1 commit into
masterfrom
openhands/fix-issue-22-args-spaces

Conversation

@12end

@12end 12end commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #22: Arguments containing spaces are incorrectly split after encryption/decryption roundtrip.

Problem

cargs.Init previously used strings.Join(args, " ") and strings.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 split hello world into 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 decryption
  • cargs_test.go: Add roundtrip tests covering simple args, args with spaces, multiple spaces, leading/trailing spaces, empty strings, and multiple args with spaces

Testing

go test -tags cargs -v

All 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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug:包含空格的参数值在加解密后会被错误拆分,导致参数个数/内容丢失

2 participants