]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix dynamic string usage as safe input
authorvrana <jakubv@fb.com>
Mon, 4 Feb 2013 19:27:16 +0000 (11:27 -0800)
committervrana <jakubv@fb.com>
Mon, 4 Feb 2013 19:34:32 +0000 (11:34 -0800)
Test Plan: Copied the code in a script, changed `phutil_passthru()` to `echo csprintf()` and ran it.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4805

src/workflow/ArcanistCommitWorkflow.php

index ab6872506709709ca74a2ce1ff6c492ea08aab1d..9570c94d30e30a7b97154292e31c3ec522dd13b2 100644 (file)
@@ -144,15 +144,20 @@ EOTEXT
     $tmp_file = new TempFile();
     Filesystem::writeFile($tmp_file, $message);
 
-    $command = $this->getSVNCommitCommand();
-    chdir($repository_api->getPath());
-
-    $err = phutil_passthru(
-      $command,
+    $command = csprintf(
+      'svn commit %Ls --encoding utf-8 -F %s',
       $files,
-      $tmp_file
-    );
+      $tmp_file);
+
+    // make sure to specify LANG on non-windows systems to surpress any fancy
+    // warnings; see @{method:getSVNLangEnvVar}.
+    if (!phutil_is_windows()) {
+      $command = csprintf('LANG=%C %C', $this->getSVNLangEnvVar(), $command);
+    }
 
+    chdir($repository_api->getPath());
+
+    $err = phutil_passthru('%C', $command);
     if ($err) {
       throw new Exception("Executing 'svn commit' failed!");
     }
@@ -296,16 +301,6 @@ EOTEXT
     return $locale;
   }
 
-  private function getSVNCommitCommand() {
-    $command = 'svn commit %Ls --encoding utf-8 -F %s';
-    // make sure to specify LANG on non-windows systems to surpress any fancy
-    // warnings; see @{method:getSVNLangEnvVar}.
-    if (!phutil_is_windows()) {
-      $command = 'LANG='.$this->getSVNLangEnvVar().' '.$command;
-    }
-    return $command;
-  }
-
   private function runSanityChecks(array $revision) {
     $repository_api = $this->getRepositoryAPI();
     $revision_id = $revision['id'];