mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Normalize template root directories in builds
This commit is contained in:
2 files changed
+9
-3
No files matched your search
@@ -298,6 +298,9 @@ class Builds extends Action
|
||||
|
||||
$templateRootDirectory = $template->getAttribute('rootDirectory', '');
|
||||
$templateRootDirectory = \trim($templateRootDirectory, '/');
|
||||
while (\str_starts_with($templateRootDirectory, './')) {
|
||||
$templateRootDirectory = \substr($templateRootDirectory, 2);
|
||||
}
|
||||
if ($templateRootDirectory !== '' && \preg_match('#(^|/)\.\.(/|$)#', $templateRootDirectory)) {
|
||||
throw new \Exception('Invalid template root directory');
|
||||
}
|
||||
@@ -423,6 +426,9 @@ class Builds extends Action
|
||||
|
||||
$templateRootDirectory = $template->getAttribute('rootDirectory', '');
|
||||
$templateRootDirectory = \trim($templateRootDirectory, '/');
|
||||
while (\str_starts_with($templateRootDirectory, './')) {
|
||||
$templateRootDirectory = \substr($templateRootDirectory, 2);
|
||||
}
|
||||
if ($templateRootDirectory !== '' && \preg_match('#(^|/)\.\.(/|$)#', $templateRootDirectory)) {
|
||||
throw new \Exception('Invalid template root directory');
|
||||
}
|
||||
|
||||
@@ -2274,7 +2274,7 @@ class SitesCustomServerTest extends Scope
|
||||
$deployment = $this->createTemplateDeployment($siteId, [
|
||||
'repository' => $template['providerRepositoryId'],
|
||||
'owner' => $template['providerOwner'],
|
||||
'rootDirectory' => \ltrim($template['frameworks'][0]['providerRootDirectory'], './'),
|
||||
'rootDirectory' => $template['frameworks'][0]['providerRootDirectory'],
|
||||
'type' => 'tag',
|
||||
'reference' => $template['providerVersion'],
|
||||
'activate' => true
|
||||
@@ -2345,7 +2345,7 @@ class SitesCustomServerTest extends Scope
|
||||
$deployment = $this->createTemplateDeployment($siteId, [
|
||||
'repository' => $template['providerRepositoryId'],
|
||||
'owner' => $template['providerOwner'],
|
||||
'rootDirectory' => \ltrim($template['frameworks'][0]['providerRootDirectory'], './'),
|
||||
'rootDirectory' => $template['frameworks'][0]['providerRootDirectory'],
|
||||
'type' => 'branch',
|
||||
'reference' => 'main',
|
||||
'activate' => true
|
||||
@@ -2423,7 +2423,7 @@ class SitesCustomServerTest extends Scope
|
||||
$deployment = $this->createTemplateDeployment($siteId, [
|
||||
'repository' => $template['providerRepositoryId'],
|
||||
'owner' => $template['providerOwner'],
|
||||
'rootDirectory' => \ltrim($template['frameworks'][0]['providerRootDirectory'], './'),
|
||||
'rootDirectory' => $template['frameworks'][0]['providerRootDirectory'],
|
||||
'type' => 'commit',
|
||||
'reference' => $latestCommit,
|
||||
'activate' => true
|
||||
|
||||
Reference in new issue
Block a user