some bugfixes

This commit is contained in:
Roman 2024-05-04 16:40:37 +02:00
parent 4b6554b870
commit 653281bc2c
4 changed files with 15 additions and 10 deletions

@ -91,23 +91,16 @@ abstract class Document {
public function sendHeaders(): void { public function sendHeaders(): void {
if ($this->cspEnabled) { if ($this->cspEnabled) {
$frameSrc = [];
$captchaProvider = $this->getSettings()->getCaptchaProvider(); $captchaProvider = $this->getSettings()->getCaptchaProvider();
if ($captchaProvider instanceof GoogleRecaptchaProvider) { if ($captchaProvider instanceof GoogleRecaptchaProvider) {
$frameSrc[] = "https://www.google.com/recaptcha/";
$frameSrc[] = "https://recaptcha.google.com/recaptcha/";
$this->cspWhitelist[] = "https://www.google.com/recaptcha/"; $this->cspWhitelist[] = "https://www.google.com/recaptcha/";
$this->cspWhitelist[] = "https://www.gstatic.com/recaptcha/"; $this->cspWhitelist[] = "https://www.gstatic.com/recaptcha/";
} else if ($captchaProvider instanceof HCaptchaProvider) { } else if ($captchaProvider instanceof HCaptchaProvider) {
$frameSrc[] = "https://hcaptcha.com";
$frameSrc[] = "https://*.hcaptcha.com";
$this->cspWhitelist[] = "https://hcaptcha.com"; $this->cspWhitelist[] = "https://hcaptcha.com";
$this->cspWhitelist[] = "https://*.hcaptcha.com"; $this->cspWhitelist[] = "https://*.hcaptcha.com";
} }
$cspWhiteList = implode(" ", $this->cspWhitelist); $cspWhiteList = implode(" ", $this->cspWhitelist);
$frameSrc = implode(" ", $frameSrc);
$csp = [ $csp = [
"default-src $cspWhiteList 'self'", "default-src $cspWhiteList 'self'",
"object-src 'none'", "object-src 'none'",
@ -116,7 +109,7 @@ abstract class Document {
"img-src 'self' 'unsafe-inline' data: https:;", "img-src 'self' 'unsafe-inline' data: https:;",
"script-src $cspWhiteList 'nonce-$this->cspNonce'", "script-src $cspWhiteList 'nonce-$this->cspNonce'",
"frame-ancestors 'self'", "frame-ancestors 'self'",
"frame-src $frameSrc 'self'", "frame-src $cspWhiteList 'self'",
]; ];
$compiledCSP = implode("; ", $csp); $compiledCSP = implode("; ", $csp);

@ -16,7 +16,9 @@ abstract class TemplateView extends View {
return []; return [];
} }
public function loadParameters(array &$parameters) { public function loadParameters(array &$parameters): void {
$this->loadView();
$siteParameters = [ $siteParameters = [
"title" => $this->title, "title" => $this->title,

@ -42,7 +42,12 @@ abstract class View extends StaticView {
} }
// Virtual Methods // Virtual Methods
public function loadView() { } public function loadView(): void {
$language = $this->getContext()->getLanguage();
foreach ($this->langModules as $module) {
$language->loadModule($module);
}
}
public function getCode(): string { public function getCode(): string {

@ -783,6 +783,11 @@ class DatabaseEntityHandler implements Persistable {
private function prepareRow(DatabaseEntity $entity, string $action, ?array $properties = null): bool|array { private function prepareRow(DatabaseEntity $entity, string $action, ?array $properties = null): bool|array {
$row = []; $row = [];
if ($entity->getId() !== null) {
$row["id"] = $entity->getId();
}
foreach ($this->columns as $propertyName => $column) { foreach ($this->columns as $propertyName => $column) {
if ($properties !== null && !in_array($propertyName, $properties)) { if ($properties !== null && !in_array($propertyName, $properties)) {
continue; continue;