fix: handle proper tokenization for --extra-params flag#2822
Draft
valeriobelli wants to merge 1 commit into
Draft
fix: handle proper tokenization for --extra-params flag#2822valeriobelli wants to merge 1 commit into
--extra-params flag#2822valeriobelli wants to merge 1 commit into
Conversation
`--extra-params` was split naively on spaces (`val.split(' ')`), which
broke any argument containing a legitimate space and leaked the quote
characters through, e.g.:
--extra-params='-destination "iOS Simulator" CODE_SIGNING_ALLOWED=NO'
--extra-params='EXCLUDED_ARCHS="arm64 i386"'
Replace the split with a shared, quote-aware `tokenize` utility in`
`cli-tools`. It honors single/double quotes, joins adjacent quoted and
unquoted segments into one token, and does no shell interpretation
values like `OTHER_LDFLAGS=$(inherited)` and Windows gradle paths
(`C:\keys\app.jks`) reach the tool verbatim. Empty/whitespace-only arguments
yields no arguments, and an unterminated quote throws a clear error.
Wired into xcodebuild (buildOptions) and gradle (buildAndroid, which is
also reused by run-android). The xcodebuild build log now quotes
arguments containing whitespace so it stays copy-pasteable.
Additionally, the apple-related `buildProject` function accounts for
this change when printing the generated `xcodebuild` command, enabling
effective copy-and-paste.
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
--extra-paramswas split naively on spaces (val.split(' ')), which broke any argument containing a legitimate space and leaked the quote characters through, e.g.:Replace the split with a shared, quote-aware
tokenizeCommandutility incli-tools. It honors single/double quotes, joins adjacent quoted and unquoted segments into one token, and does no shell interpretation; values likeOTHER_LDFLAGS=$(inherited)and Windows Gradle paths (C:\keys\app.jks) reach the tool verbatim. Empty/whitespace-only arguments yield no arguments, and an unterminated quote throws a clear error.Wired into XcodeBuild (buildOptions) and Gradle (buildAndroid, which is also reused by run-android). The Xcode build log now quotes arguments containing whitespace so it stays copy-pasteable.
Additionally, the apple-related
buildProjectfunction accounts for this change when printing the generatedxcodebuildcommand, enabling effective copy-and-paste.Test Plan
Added tests in
packages/cli-tools/src/__tests__/tokenizeCommand.test.tsasserting some use cases.$ jest packages/cli-tools/src/__tests__/tokenize.test.ts PASS unit packages/cli-tools/src/__tests__/tokenize.test.ts tokenize ✓ splits space-separated xcodebuild arguments ✓ splits space-separated gradle properties ✓ keeps a double-quoted xcodebuild destination with spaces in one token ✓ keeps a single-quoted destination specifier with spaces in one token ✓ strips the surrounding quotes from a quoted path containing a space ✓ joins an unquoted build-setting name with its quoted, space-containingvalue ✓ collapses extra whitespace (spaces and tabs) between arguments ✓ passes xcodebuild build-setting syntax such as $(inherited) through verbatim ✓ keeps backslashes literal so Windows gradle paths survive ✓ returns an empty array for empty input ✓ returns an empty array for whitespace-only input ✓ drops a stray empty quoted argument ✓ throws on an unterminated double quote ✓ throws on an unterminated single quote Test Suites: 1 passed, 1 totalChecklist
react-nativecheckout (instructions).