Skip to content

fix: handle double quotes inside single-quoted GYP strings#3346

Open
bitpshr wants to merge 1 commit into
nodejs:mainfrom
bitpshr:fix/gyp-config-double-quotes
Open

fix: handle double quotes inside single-quoted GYP strings#3346
bitpshr wants to merge 1 commit into
nodejs:mainfrom
bitpshr:fix/gyp-config-double-quotes

Conversation

@bitpshr

@bitpshr bitpshr commented Jul 12, 2026

Copy link
Copy Markdown

Fixes #3333.

parseConfigGypi() converted single quotes to double quotes with a bare config.replace(/'/g, '"'), which produced invalid JSON whenever a single-quoted string contained " (e.g. GYP condition strings like 'OS=="win"', used by native addons such as canvas). It now converts each single-quoted string individually and escapes the double quotes inside it. Added a regression test.

parseConfigGypi() converted single quotes to double quotes with a bare
`config.replace(/'/g, '"')`, which produced invalid JSON when a
single-quoted string contained double-quote characters, such as the GYP
condition strings used by native addons (e.g. `'OS=="win"'`). Convert
each single-quoted string individually and escape the double quotes
inside it instead.

Fixes: nodejs#3333
Signed-off-by: Paul Bouchon <mail@bitpshr.net>
@bitpshr
bitpshr force-pushed the fix/gyp-config-double-quotes branch from 3b1abb1 to cf18d58 Compare July 20, 2026 22:13
@bitpshr

bitpshr commented Jul 20, 2026

Copy link
Copy Markdown
Author

Rebased this onto main to pick up the undici 8.7.0 fix from #3345, which looks like what was causing the Windows + Node 26 test-download timeouts here (this PR itself is just GYP string escaping, unrelated to downloads). The create-config-gypi tests pass locally.

@legendecas the CI run is sitting in action_required since it's a fork PR, so it needs an approval to actually run. Whenever you get a chance.

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.

parseConfigGypi fails on GYP files whose single-quoted strings contain double-quote characters (e.g. canvas, 'OS=="win"' conditions)

1 participant