git-diff
git-diff copied to clipboard
Escape shell arguments
Passing strings to diff as unescaped shell arguments to printf can result in unexpected (and potentially exploitable) behaviour if the strings contain special characters, such as backticks (`).
This adds a basic test which replicates the bug, and replaces the use of JSON.stringify with a basic escapeShellArg function, adapted from StackOverflow.
It would probably be good to get review from someone with more security knowledge.