Skip to content

Conversation

alharirihamzah
Copy link
Contributor

@alharirihamzah alharirihamzah commented Jul 5, 2024

This PR fixes whitespaces in commands and arrgs when calling spawnSync()

A simple fix is to always wrap commands and arrgs with double quotes to avoid similar issues.

Issue: #820

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

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

Thanks for looking into the fix for this, that's really appreciated.

I haven't had a chance to test out the spawn behaviours properly, but have left some comments for an initial review.

Comment on lines -120 to +129
wizer,
`"${wizer}"`,
[
"--inherit-env=true",
"--allow-wasi",
"--dir=.",
...starlingMonkey ? [`--dir=${dirname(wizerInput)}`] : [],
`--wasm-bulk-memory=true`,
"-r _start=wizer.resume",
`-o=${output}`,
wasmEngine,
`-o="${output}"`,
`"${wasmEngine}"`,
Copy link
Contributor

@guybedford guybedford Jul 5, 2024

Choose a reason for hiding this comment

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

Normally spawnSync doesn't require escaping of arguments as it automatically handles this (and this is also why windowsVerbatimArguments is an option).

Therefore unless we can prove there is a test case where this fails, I'm pretty sure this code path should support spaces okay in the command and arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it still needs the double quotes around the input on L#120 and around the args on L#128-L#129

@guybedford
Copy link
Contributor

I've posted #822 with just the check changes, which I believe may be sufficient, but please let me know if I'm mistaken as well.

@alharirihamzah
Copy link
Contributor Author

Hi @guybedford!
Sorry I couldn't answer fast enough and really thanks for your time looking into this, much appreciated 😄

I have tried fixing only the check in containsSyntaxErrors #L9 but then it broke in the other spawnSync() invocation in compileApplicationToWasm - L#119
Screenshot 2024-07-09 at 08 47 01

It still broken when including the fix for the input command for wizerProcess in compileApplicationToWasm #L120 without the args
Screenshot 2024-07-09 at 08 48 14

And including the fix for the arg wasmEngine in compileApplicationToWasm #L129 still not enough
Screenshot 2024-07-09 at 08 49 24

And finally by including the fix for the output arg in compileApplicationToWasm #L128 fix the whole chain 🙃
Screenshot 2024-07-09 at 08 49 58

I hope this clear things out 😃
Let me know if you have any other questions and thanks again 🙏

@guybedford
Copy link
Contributor

Okay, thank you for confirming all the usages are required. Yeah it seems this is because of the shell: true, although I do wonder why we even need that in the invocation.

Regardless will merge this for the next release, thank you!.

@guybedford guybedford merged commit 68d77fb into fastly:main Jul 9, 2024
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