telesoho / vscode-markdown-paste-image

Smartly paste for Markdown.
MIT License
135 stars 41 forks source link

Fix the Execution of Commands Containing Whitespaces #61

Closed manuth closed 2 years ago

manuth commented 2 years ago

Currently, commands are being executed using child_process.exec which doesn't allow passing parameters. Therefore, commands are generated dynamically as seen here: https://github.com/telesoho/vscode-markdown-paste-image/blob/3ef1162ecfca16bf04944bc0028fbe0b42ef0ac2/src/paster.ts#L55

This causes commands with arguments containing whitespaces to break.

As opposed to child_process.exec, child_process.spawn allows passing arguments (as a string array). This PR replaces the use of child_process.exec with child_process.spawn fixing all issues related to whitespaces.

Marging this PR will fix #60

vezaynk commented 2 years ago

I'm sure this works, but it is overkill for quote wrapping. I'm trying to find the NodeJS code that deals with it to copy their implementation.

manuth commented 2 years ago

Awesome! thanks for taking care about it 😄

vezaynk commented 2 years ago

I can't figure out how nodeJS sanitizes it but I confirmed that it works. This looks good.

Could you bump the last number of the version? It will be good to merge after that.

manuth commented 2 years ago

Couldn't find it either - I couldn't find the process_wrap of their code base. Alright, will do!

vezaynk commented 2 years ago

@manuth Thank you!