]> khamidou — GitHub mirrors - arcanist.git/commit
Fix escaping of "git log ---format" command on Windows
authorepriestley <git@epriestley.com>
Mon, 5 Mar 2012 21:22:41 +0000 (13:22 -0800)
committerepriestley <git@epriestley.com>
Mon, 5 Mar 2012 21:22:41 +0000 (13:22 -0800)
commit0e35dc64a9c298fdfd8e7ad8f668d878ab89d8ec
tree4b5aa62d3ec7c8d036ef840f89269aa0f5e017df
parentd7b10e4f443eb709ce901479fc25debbc83e039a
Fix escaping of "git log ---format" command on Windows

Summary:
On Windows, the PHP function escapeshellarg() replaces '%' with ' ' (space). This is apparently because there is no safe way to escape % inside of strings.

cmd.exe does use "^" as an escape character, so I think replacing "xyz" with "^x^y^z" might work for arbitrary strings (maybe?), or at least some subset of strings, but I don't know cmd.exe well enough to make that call without being concerned I'm introducing a security issue.

Although this patch is dumb, it's certinaly safe, and can only do something wrong if the user has environmental variables like H, P, T, or x01, in which case they're sort of asking for it.

cmd.exe also truncates output on \0, so use \1 as a delimiter instead.

Seriously it's like this thing was written in 1982 and never ever changed.

Test Plan: Created D1783 successfully after applying this patch.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley
Maniphest Tasks: T124

Differential Revision: https://secure.phabricator.com/D1785
src/repository/api/git/ArcanistGitAPI.php