Skip to content

Commit 663bf2a

Browse files
Merge branch '7.1' into 7.2
* 7.1: [Validator] Fix 58691 (missing plural-options in serbian language translation) profiler form data collector extart value property if it is setted [Process] Fix escaping /X arguments on Windows fix the constant being used fix the path separator being used fix the directory separator being used ignore case of built-in cmd.exe commands [Process] Improve test cleanup by unlinking in a `finally` block [Notifier] Fix test with hard coded date in `SmsboxTransportTest` [Process] Return built-in cmd.exe commands directly in ExecutableFinder Re-add missing Profiler shortcuts on Profiler homepage [Config] Handle Phar absolute path in `FileLocator` [Runtime] Remove unused `SKIPIF` from `dotenv_overload.phpt`
2 parents da599ce + aee645a commit 663bf2a

File tree

11 files changed

+173
-136
lines changed

11 files changed

+173
-136
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,10 @@
646646
<td>{{ profiler_dump(value) }}</td>
647647
<td>
648648
{# values can be stubs #}
649-
{% set option_value = value.value|default(value) %}
650-
{% set resolved_option_value = data.resolved_options[option].value|default(data.resolved_options[option]) %}
649+
{% set option_value = (value.value is defined) ? value.value : value %}
650+
{% set resolved_option_value = (data.resolved_options[option].value is defined)
651+
? data.resolved_options[option].value
652+
: data.resolved_options[option] %}
651653
{% if resolved_option_value == option_value %}
652654
<em class="font-normal text-muted">same as passed value</em>
653655
{% else %}

src/Symfony/Component/Config/FileLocator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ private function isAbsolutePath(string $file): bool
8787
&& ('\\' === $file[2] || '/' === $file[2])
8888
)
8989
|| parse_url($file, \PHP_URL_SCHEME)
90+
|| str_starts_with($file, 'phar:///') // "parse_url()" doesn't handle absolute phar path, despite being valid
9091
) {
9192
return true;
9293
}

src/Symfony/Component/Config/Tests/FileLocatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static function getIsAbsolutePathTests(): array
3838
['\\server\\foo.xml'],
3939
['https://server/foo.xml'],
4040
['phar://server/foo.xml'],
41+
['phar:///server/foo.xml'],
4142
];
4243
}
4344

src/Symfony/Component/Notifier/Bridge/Smsbox/Tests/SmsboxTransportTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,18 @@ public function testSmsboxOptionsInvalidDateTimeAndDate()
206206
return $response;
207207
});
208208

209+
$dateTime = new \DateTimeImmutable('+1 day');
210+
209211
$this->expectException(\InvalidArgumentException::class);
210212
$this->expectExceptionMessage("Either Symfony\Component\Notifier\Bridge\Smsbox\SmsboxOptions::dateTime() or Symfony\Component\Notifier\Bridge\Smsbox\SmsboxOptions::date() and Symfony\Component\Notifier\Bridge\Smsbox\SmsboxOptions::hour() must be called, but not both.");
211-
$dateTime = \DateTimeImmutable::createFromFormat('d/m/Y H:i', '01/11/2024 18:00', new \DateTimeZone('UTC'));
212213
$message = new SmsMessage('+33612345678', 'Hello');
213214

214215
$smsboxOptions = (new SmsboxOptions())
215216
->mode(Mode::Expert)
216217
->sender('SENDER')
217218
->strategy(Strategy::Marketing)
218219
->dateTime($dateTime)
219-
->date('01/01/2024');
220+
->date($dateTime->format('d/m/Y'));
220221

221222
$transport = $this->createTransport($client);
222223

src/Symfony/Component/Process/ExecutableFinder.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
*/
2020
class ExecutableFinder
2121
{
22+
private const CMD_BUILTINS = [
23+
'assoc', 'break', 'call', 'cd', 'chdir', 'cls', 'color', 'copy', 'date',
24+
'del', 'dir', 'echo', 'endlocal', 'erase', 'exit', 'for', 'ftype', 'goto',
25+
'help', 'if', 'label', 'md', 'mkdir', 'mklink', 'move', 'path', 'pause',
26+
'popd', 'prompt', 'pushd', 'rd', 'rem', 'ren', 'rename', 'rmdir', 'set',
27+
'setlocal', 'shift', 'start', 'time', 'title', 'type', 'ver', 'vol',
28+
];
29+
2230
private array $suffixes = [];
2331

2432
public function __construct()
@@ -57,6 +65,11 @@ public function addSuffix(string $suffix): void
5765
*/
5866
public function find(string $name, ?string $default = null, array $extraDirs = []): ?string
5967
{
68+
// windows built-in commands that are present in cmd.exe should not be resolved using PATH as they do not exist as exes
69+
if ('\\' === \DIRECTORY_SEPARATOR && \in_array(strtolower($name), self::CMD_BUILTINS, true)) {
70+
return $name;
71+
}
72+
6073
$dirs = array_merge(
6174
explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
6275
$extraDirs

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ private function escapeArgument(?string $argument): string
16311631
if (str_contains($argument, "\0")) {
16321632
$argument = str_replace("\0", '?', $argument);
16331633
}
1634-
if (!preg_match('/[\/()%!^"<>&|\s]/', $argument)) {
1634+
if (!preg_match('/[()%!^"<>&|\s]/', $argument)) {
16351635
return $argument;
16361636
}
16371637
$argument = preg_replace('/(\\\\+)$/', '$1$1', $argument);

src/Symfony/Component/Process/Tests/ExecutableFinderTest.php

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,20 @@ public function testFindBatchExecutableOnWindows()
150150

151151
$target = tempnam(sys_get_temp_dir(), 'example-windows-executable');
152152

153-
touch($target);
154-
touch($target.'.BAT');
155-
156-
$this->assertFalse(is_executable($target));
153+
try {
154+
touch($target);
155+
touch($target.'.BAT');
157156

158-
putenv('PATH='.sys_get_temp_dir());
157+
$this->assertFalse(is_executable($target));
159158

160-
$finder = new ExecutableFinder();
161-
$result = $finder->find(basename($target), false);
159+
putenv('PATH='.sys_get_temp_dir());
162160

163-
unlink($target);
164-
unlink($target.'.BAT');
161+
$finder = new ExecutableFinder();
162+
$result = $finder->find(basename($target), false);
163+
} finally {
164+
unlink($target);
165+
unlink($target.'.BAT');
166+
}
165167

166168
$this->assertSamePath($target.'.BAT', $result);
167169
}
@@ -171,17 +173,31 @@ public function testFindBatchExecutableOnWindows()
171173
*/
172174
public function testEmptyDirInPath()
173175
{
174-
putenv(sprintf('PATH=%s:', \dirname(\PHP_BINARY)));
176+
putenv(sprintf('PATH=%s%s', \dirname(\PHP_BINARY), \PATH_SEPARATOR));
175177

176-
touch('executable');
177-
chmod('executable', 0700);
178+
try {
179+
touch('executable');
180+
chmod('executable', 0700);
178181

179-
$finder = new ExecutableFinder();
180-
$result = $finder->find('executable');
182+
$finder = new ExecutableFinder();
183+
$result = $finder->find('executable');
181184

182-
$this->assertSame('./executable', $result);
185+
$this->assertSame(sprintf('.%sexecutable', \DIRECTORY_SEPARATOR), $result);
186+
} finally {
187+
unlink('executable');
188+
}
189+
}
183190

184-
unlink('executable');
191+
public function testFindBuiltInCommandOnWindows()
192+
{
193+
if ('\\' !== \DIRECTORY_SEPARATOR) {
194+
$this->markTestSkipped('Can be only tested on windows');
195+
}
196+
197+
$finder = new ExecutableFinder();
198+
$this->assertSame('rmdir', strtolower($finder->find('RMDIR')));
199+
$this->assertSame('cd', strtolower($finder->find('cd')));
200+
$this->assertSame('move', strtolower($finder->find('MoVe')));
185201
}
186202

187203
private function assertSamePath($expected, $tested)

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,12 @@ public function testGetCommandLine()
14691469
{
14701470
$p = new Process(['/usr/bin/php']);
14711471

1472-
$expected = '\\' === \DIRECTORY_SEPARATOR ? '"/usr/bin/php"' : "'/usr/bin/php'";
1472+
$expected = '\\' === \DIRECTORY_SEPARATOR ? '/usr/bin/php' : "'/usr/bin/php'";
1473+
$this->assertSame($expected, $p->getCommandLine());
1474+
1475+
$p = new Process(['cd', '/d']);
1476+
1477+
$expected = '\\' === \DIRECTORY_SEPARATOR ? 'cd /d' : "'cd' '/d'";
14731478
$this->assertSame($expected, $p->getCommandLine());
14741479
}
14751480

src/Symfony/Component/Runtime/Tests/phpt/dotenv_overload.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
Test Dotenv overload
3-
--SKIPIF--
4-
<?php require dirname(__DIR__, 6).'/vendor/autoload.php'; if (4 > (new \ReflectionMethod(\Symfony\Component\Dotenv\Dotenv::class, 'bootEnv'))->getNumberOfParameters()) echo 'Skip because Dotenv version is too low';
53
--INI--
64
display_errors=1
75
--FILE--

0 commit comments

Comments
 (0)