Skip to content

Commit 36a017f

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: [Form] Fix same choice loader with different choice values [Filesystem] Safeguard (sym)link calls
2 parents 3a44421 + 815412e commit 36a017f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Filesystem.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ private function isReadable(string $filename): bool
329329
*/
330330
public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false)
331331
{
332+
self::assertFunctionExists('symlink');
333+
332334
if ('\\' === \DIRECTORY_SEPARATOR) {
333335
$originDir = strtr($originDir, '/', '\\');
334336
$targetDir = strtr($targetDir, '/', '\\');
@@ -364,6 +366,8 @@ public function symlink(string $originDir, string $targetDir, bool $copyOnWindow
364366
*/
365367
public function hardlink(string $originFile, $targetFiles)
366368
{
369+
self::assertFunctionExists('link');
370+
367371
if (!$this->exists($originFile)) {
368372
throw new FileNotFoundException(null, 0, null, $originFile);
369373
}
@@ -730,13 +734,22 @@ private function getSchemeAndHierarchy(string $filename): array
730734
return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
731735
}
732736

737+
private static function assertFunctionExists(string $func): void
738+
{
739+
if (!\function_exists($func)) {
740+
throw new IOException(sprintf('Unable to perform filesystem operation because the "%s()" function has been disabled.', $func));
741+
}
742+
}
743+
733744
/**
734745
* @param mixed ...$args
735746
*
736747
* @return mixed
737748
*/
738-
private static function box(callable $func, ...$args)
749+
private static function box(string $func, ...$args)
739750
{
751+
self::assertFunctionExists($func);
752+
740753
self::$lastError = null;
741754
set_error_handler(__CLASS__.'::handleError');
742755
try {

0 commit comments

Comments
 (0)