Skip to content

Escape replacement values in Gemfile and Composer payloads - #46

Merged
andrew merged 2 commits into
mainfrom
fix-gemfile-ruby-escaping
Nov 4, 2026
Merged

andrew merged 2 commits into
mainfrom
fix-gemfile-ruby-escaping

Conversation

@andrew

@andrew andrew commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Bundler replacements used Go's %q, which leaves Ruby interpolation active and emits Unicode escapes that Ruby reads differently. Gem names, paths, git URLs and refs are now encoded as Ruby string literals, so supplied values stay literal when the Gemfile is evaluated.

Composer repository payloads had the same problem: %q inside a JSON string emits escapes like \x00 that are not valid JSON, so composer config rejected paths or URLs containing control bytes or non-printable Unicode. The payload is now built with encoding/json.

Regression tests cover edited and appended Gemfile entries (interpolation, quotes, backslashes, control bytes, Unicode) and check that Composer payloads parse as JSON and round-trip the original value.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 13:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Go's %q emits escapes like \x00 that are not valid JSON, so composer config rejected payloads with control bytes or non-printable Unicode.
@andrew andrew changed the title Escape Ruby strings when writing Gemfile replacements Escape replacement values in Gemfile and Composer payloads Nov 4, 2026
@andrew
andrew merged commit 8bdf438 into main Nov 4, 2026
5 checks passed
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.

2 participants