Skip to content

Commit

Permalink
Merge branch '6.2' into 6.3
Browse files Browse the repository at this point in the history
* 6.2:
  Fix merge
  [Translation] Fix handling of null messages in `ArrayLoader`
  [Console] Remove exec and replace it by shell_exec
  [Security] Skip clearing CSRF Token on stateless logout
  • Loading branch information
nicolas-grekas committed May 19, 2023
2 parents ce1cfc7 + da99563 commit 2211316
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
6 changes: 2 additions & 4 deletions Helper/QuestionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,11 @@ private function isInteractiveInput($inputStream): bool
return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
}

if (!\function_exists('exec')) {
if (!\function_exists('shell_exec')) {
return self::$stdinIsInteractive = true;
}

exec('stty 2> /dev/null', $output, $status);

return self::$stdinIsInteractive = 1 !== $status;
return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
}

/**
Expand Down
8 changes: 3 additions & 5 deletions Terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ public static function hasSttyAvailable(): bool
return self::$stty;
}

// skip check if exec function is disabled
if (!\function_exists('exec')) {
// skip check if shell_exec function is disabled
if (!\function_exists('shell_exec')) {
return false;
}

exec('stty 2>&1', $output, $exitcode);

return self::$stty = 0 === $exitcode;
return self::$stty = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
}

private static function initDimensions(): void
Expand Down
4 changes: 2 additions & 2 deletions Tests/Helper/QuestionHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public function testAskHiddenResponse()
$this->assertEquals('8AM', $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("8AM\n")), $this->createOutputInterface(), $question));
}

public function testAskHiddenResponseTrimmed()
public function testAskHiddenResponseNotTrimmed()
{
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test is not supported on Windows');
Expand All @@ -440,7 +440,7 @@ public function testAskHiddenResponseTrimmed()
$question->setHidden(true);
$question->setTrimmable(false);

$this->assertEquals(' 8AM', $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream(' 8AM')), $this->createOutputInterface(), $question));
$this->assertEquals(' 8AM'.\PHP_EOL, $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream(' 8AM'.\PHP_EOL)), $this->createOutputInterface(), $question));
}

public function testAskMultilineResponseWithEOF()
Expand Down
4 changes: 2 additions & 2 deletions Tests/TerminalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function testSttyOnWindows()
$this->markTestSkipped('Must be on windows');
}

$sttyString = exec('(stty -a | grep columns) 2>&1', $output, $exitcode);
if (0 !== $exitcode) {
$sttyString = shell_exec('(stty -a | grep columns) 2> NUL');
if (!$sttyString) {
$this->markTestSkipped('Must have stty support');
}

Expand Down

0 comments on commit 2211316

Please sign in to comment.