fix(exec): properly handles paths with spaces and quotes#365
Merged
Conversation
Member
Author
Member
Author
Contributor
|
@nfischer: Can we add a test for this? (If possible), otherwise, LGTM! |
Member
Author
|
@ariporad It might be difficult to test it as-is, since it involves creating a directory with that name and mocking If you can think of a unit test however, feel free to add it. I just couldn't think of anything. |
Member
Author
|
I'm going to merge this now. If we can think of any tests for this, we can add them later on. |
nfischer
added a commit
that referenced
this pull request
Feb 19, 2016
fix(exec): properly handles paths with spaces and quotes
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.
This fixes #17. This is based off #263, but it also escapes quotes in the path.
The issue comes from the fact that
exec()executes a script created in the temporary directory. On unix systems, this is usually/tmp/, which has no unusual characters in the name. Windows users usually have a temporary directory that is a subdirectory of their home folder (which has their username as part of the path). Therefore, Windows users with usernames containing either a space or a"couldn't useexec()properly.This now properly surrounds the strings with quotes, and escapes any quote characters inside for security, preventing scenarios, such as creating a directory named
/tmp"; echo hijacked; echo "(perhaps$TMPis modified to point there, and this is chosen as the temporary directory).echo hijackedrepresents an arbitrary command. As it's currently implemented, #263 is still susceptible.