mirror of
https://github.com/friendica/friendica
synced 2025-04-28 02:30:16 +00:00
Basepath Hardening
This commit is contained in:
parent
e0911efc87
commit
1480380af6
2 changed files with 55 additions and 13 deletions
|
@ -19,15 +19,21 @@ class BasePath
|
|||
*/
|
||||
public static function create($basePath, array $server = [])
|
||||
{
|
||||
if (!$basePath && !empty($server['DOCUMENT_ROOT'])) {
|
||||
if ((!$basePath || !is_dir($basePath)) && !empty($server['DOCUMENT_ROOT'])) {
|
||||
$basePath = $server['DOCUMENT_ROOT'];
|
||||
}
|
||||
|
||||
if (!$basePath && !empty($server['PWD'])) {
|
||||
if ((!$basePath || !is_dir($basePath)) && !empty($server['PWD'])) {
|
||||
$basePath = $server['PWD'];
|
||||
}
|
||||
|
||||
return self::getRealPath($basePath);
|
||||
$basePath = self::getRealPath($basePath);
|
||||
|
||||
if (!is_dir($basePath)) {
|
||||
throw new \Exception(sprintf('\'%s\' is not a valid basepath', $basePath));
|
||||
}
|
||||
|
||||
return $basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue