Skip to content

Commit dddc22e

Browse files
committed
Merge branch 'master' into 3.0
2 parents 446a484 + 029305e commit dddc22e

File tree

8 files changed

+20
-11
lines changed

8 files changed

+20
-11
lines changed

Diff for: src/Fixer.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ public function generateDiff($filePath=null, $colors=true)
247247

248248
// We must use something like shell_exec() because whitespace at the end
249249
// of lines is critical to diff files.
250-
$cmd = "diff -u -L\"$filename\" -LPHP_CodeSniffer \"$filename\" \"$tempName\"";
250+
$filename = escapeshellarg($filename);
251+
$cmd = "diff -u -L$filename -LPHP_CodeSniffer $filename \"$tempName\"";
252+
251253
$diff = shell_exec($cmd);
252254

253255
fclose($fixedFile);

Diff for: src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function process(File $phpcsFile, $stackPtr)
5454

5555
$fileName = $phpcsFile->getFilename();
5656

57-
$cmd = $csslintPath.' '.escapeshellarg($fileName);
57+
$cmd = escapeshellcmd($csslintPath).' '.escapeshellarg($fileName).' 2>&1';
5858
exec($cmd, $output, $retval);
5959

6060
if (is_array($output) === false) {

Diff for: src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ public function process(File $phpcsFile, $stackPtr)
7171

7272
$fileName = $phpcsFile->getFilename();
7373

74-
$cmd = "$lintPath --nosummary --notime --unix_mode \"$fileName\"";
75-
$msg = exec($cmd, $output, $retval);
74+
$lintPath = escapeshellcmd($lintPath);
75+
$cmd = '$lintPath --nosummary --notime --unix_mode '.escapeshellarg($fileName);
76+
$msg = exec($cmd, $output, $retval);
7677

7778
if (is_array($output) === false) {
7879
return;

Diff for: src/Standards/Generic/Sniffs/Debug/JSHintSniff.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ public function process(File $phpcsFile, $stackPtr)
5757

5858
$fileName = $phpcsFile->getFilename();
5959

60-
$cmd = "$rhinoPath \"$jshintPath\" \"$fileName\"";
60+
$rhinoPath = escapeshellcmd($rhinoPath);
61+
$jshintPath = escapeshellcmd($jshintPath);
62+
63+
$cmd = "$rhinoPath \"$jshintPath\" ".escapeshellarg($fileName);
6164
$msg = exec($cmd, $output, $retval);
6265

6366
if (is_array($output) === true) {

Diff for: src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public function process(File $phpcsFile, $stackPtr)
6060
}
6161
}
6262

63-
$fileName = $phpcsFile->getFilename();
63+
$fileName = escapeshellarg($phpcsFile->getFilename());
6464
if (defined('HHVM_VERSION') === false) {
65-
$cmd = $this->phpPath." -l -d error_prepend_string='' \"$fileName\" 2>&1";
65+
$cmd = escapeshellcmd($this->phpPath)." -l -d error_prepend_string='' $fileName 2>&1";
6666
} else {
67-
$cmd = $this->phpPath." -l \"$fileName\" 2>&1";
67+
$cmd = escapeshellcmd($this->phpPath)." -l $fileName 2>&1";
6868
}
6969

7070
$output = shell_exec($cmd);

Diff for: src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ public function process(File $phpcsFile, $stackPtr)
5656

5757
$fileName = $phpcsFile->getFilename();
5858

59-
$cmd = "$rhinoPath \"$jslintPath\" \"$fileName\"";
59+
$rhinoPath = escapeshellcmd($rhinoPath);
60+
$jslintPath = escapeshellcmd($jslintPath);
61+
62+
$cmd = "$rhinoPath \"$jslintPath\" ".escapeshellarg($fileName);
6063
$msg = exec($cmd, $output, $retval);
6164

6265
if (is_array($output) === true) {

Diff for: src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function process(File $phpcsFile, $stackPtr)
5555

5656
$fileName = $phpcsFile->getFilename();
5757

58-
$cmd = '"'.$jslPath.'" -nologo -nofilelisting -nocontext -nosummary -output-format __LINE__:__ERROR__ -process "'.$fileName.'"';
58+
$cmd = '"'.escapeshellcmd($jslPath).'" -nologo -nofilelisting -nocontext -nosummary -output-format __LINE__:__ERROR__ -process '.escapeshellarg($fileName);
5959
$msg = exec($cmd, $output, $retval);
6060

6161
// Variable $exitCode is the last line of $output if no error occurs, on

Diff for: src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function process(File $phpcsFile, $stackPtr)
5252
// In the command, 2>&1 is important because the code analyzer sends its
5353
// findings to stderr. $output normally contains only stdout, so using 2>&1
5454
// will pipe even stderr to stdout.
55-
$cmd = $analyzerPath.' '.$fileName.' 2>&1';
55+
$cmd = escapeshellcmd($analyzerPath).' '.escapeshellarg($fileName).' 2>&1';
5656

5757
// There is the possibility to pass "--ide" as an option to the analyzer.
5858
// This would result in an output format which would be easier to parse.

0 commit comments

Comments
 (0)