Normalize wizard gallery root safely

This commit is contained in:
Terranom674
2026-08-18 08:01:29 +02:00
parent da6e9f18d5
commit ee37484dd2

View File

@@ -45,6 +45,15 @@ function bratonien_tools_nc_connector_create_local_api_first()
} }
$gallery_root = rtrim(trim((string)$_POST['nc_gallery_root']), '/'); $gallery_root = rtrim(trim((string)$_POST['nc_gallery_root']), '/');
if (strpos($gallery_root, './') === 0)
{
$piwigo_root = realpath(PHPWG_ROOT_PATH);
if ($piwigo_root === false)
{
throw new RuntimeException('Piwigo-Stammverzeichnis konnte nicht aufgelöst werden.');
}
$gallery_root = rtrim($piwigo_root, '/').'/'.ltrim(substr($gallery_root, 2), '/');
}
if ($gallery_root === '' || $gallery_root[0] !== '/') if ($gallery_root === '' || $gallery_root[0] !== '/')
{ {
throw new RuntimeException('Der Galerie-Pfad muss ein absoluter Pfad sein.'); throw new RuntimeException('Der Galerie-Pfad muss ein absoluter Pfad sein.');