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>
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