Skip to content

Commit 2211316

Browse files
Merge branch '6.2' into 6.3
* 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
2 parents ce1cfc7 + da99563 commit 2211316

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

Helper/QuestionHelper.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,11 @@ private function isInteractiveInput($inputStream): bool
498498
return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
499499
}
500500

501-
if (!\function_exists('exec')) {
501+
if (!\function_exists('shell_exec')) {
502502
return self::$stdinIsInteractive = true;
503503
}
504504

505-
exec('stty 2> /dev/null', $output, $status);
506-
507-
return self::$stdinIsInteractive = 1 !== $status;
505+
return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
508506
}
509507

510508
/**

Terminal.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,12 @@ public static function hasSttyAvailable(): bool
123123
return self::$stty;
124124
}
125125

126-
// skip check if exec function is disabled
127-
if (!\function_exists('exec')) {
126+
// skip check if shell_exec function is disabled
127+
if (!\function_exists('shell_exec')) {
128128
return false;
129129
}
130130

131-
exec('stty 2>&1', $output, $exitcode);
132-
133-
return self::$stty = 0 === $exitcode;
131+
return self::$stty = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
134132
}
135133

136134
private static function initDimensions(): void

Tests/Helper/QuestionHelperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public function testAskHiddenResponse()
428428
$this->assertEquals('8AM', $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("8AM\n")), $this->createOutputInterface(), $question));
429429
}
430430

431-
public function testAskHiddenResponseTrimmed()
431+
public function testAskHiddenResponseNotTrimmed()
432432
{
433433
if ('\\' === \DIRECTORY_SEPARATOR) {
434434
$this->markTestSkipped('This test is not supported on Windows');
@@ -440,7 +440,7 @@ public function testAskHiddenResponseTrimmed()
440440
$question->setHidden(true);
441441
$question->setTrimmable(false);
442442

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

446446
public function testAskMultilineResponseWithEOF()

Tests/TerminalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public function testSttyOnWindows()
7777
$this->markTestSkipped('Must be on windows');
7878
}
7979

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

0 commit comments

Comments
 (0)