Skip to content

Commit 498f2c0

Browse files
committed
Add PhpVersion::isCurloptUrlCheckingFileSchemeWithOpenBasedir()
1 parent 2d47da6 commit 498f2c0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Php/PhpVersion.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,12 @@ public function hasDateTimeExceptions(): bool
327327
return $this->versionId >= 80300;
328328
}
329329

330+
public function isCurloptUrlCheckingFileSchemeWithOpenBasedir(): bool
331+
{
332+
// Before PHP 8.0, when setting CURLOPT_URL, an unparsable URL or a file:// scheme would fail if open_basedir is used
333+
// https://github.com/php/php-src/blob/php-7.4.33/ext/curl/interface.c#L139-L158
334+
// https://github.com/php/php-src/blob/php-8.0.0/ext/curl/interface.c#L128-L130
335+
return $this->versionId < 80000;
336+
}
337+
330338
}

src/Type/Php/CurlInitReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private function getUrlArgValueReturnType(mixed $urlArgValue, Type $returnType,
8181
// https://github.com/php/php-src/blob/php-8.0.0/ext/curl/interface.c#L104-L107
8282
return new NeverType();
8383
}
84-
if ($this->phpVersion->getVersionId() < 80000) {
84+
if ($this->phpVersion->isCurloptUrlCheckingFileSchemeWithOpenBasedir()) {
8585
// Before PHP 8.0 an unparsable URL or a file:// scheme would fail if open_basedir is used
8686
// Since we can't detect open_basedir properly, we'll always consider a failure possible if these
8787
// conditions are given

0 commit comments

Comments
 (0)