Skip to content

Commit

Permalink
Merge branch 'BookStackApp:release' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhollmann authored Aug 3, 2024
2 parents 883ea5b + d6021f4 commit 3824e96
Show file tree
Hide file tree
Showing 32 changed files with 550 additions and 452 deletions.
4 changes: 3 additions & 1 deletion .github/translators.txt
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,6 @@ Ohadp :: Hebrew
cbridi :: Portuguese, Brazilian
nanangsb :: Indonesian
Michal Melich (michalmelich) :: Czech
David (david-prv) :: German
David (david-prv) :: German; German Informal
Larry (lahoje) :: Swedish
Marcia dos Santos (marciab80) :: Portuguese
8 changes: 4 additions & 4 deletions app/Access/Oidc/OidcUserDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function isFullyPopulated(bool $groupSyncActive): bool
$hasEmpty = empty($this->externalId)
|| empty($this->email)
|| empty($this->name)
|| ($groupSyncActive && empty($this->groups));
|| ($groupSyncActive && $this->groups === null);

return !$hasEmpty;
}
Expand Down Expand Up @@ -57,15 +57,15 @@ protected static function getUserDisplayName(string $displayNameClaims, Provides
return implode(' ', $displayName);
}

protected static function getUserGroups(string $groupsClaim, ProvidesClaims $token): array
protected static function getUserGroups(string $groupsClaim, ProvidesClaims $token): ?array
{
if (empty($groupsClaim)) {
return [];
return null;
}

$groupsList = Arr::get($token->getAllClaims(), $groupsClaim);
if (!is_array($groupsList)) {
return [];
return null;
}

return array_values(array_filter($groupsList, function ($val) {
Expand Down
2 changes: 1 addition & 1 deletion app/Uploads/ImageRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function updateImageDetails(Image $image, $updateDetails): Image
*/
public function updateImageFile(Image $image, UploadedFile $file): void
{
if ($file->getClientOriginalExtension() !== pathinfo($image->path, PATHINFO_EXTENSION)) {
if (strtolower($file->getClientOriginalExtension()) !== strtolower(pathinfo($image->path, PATHINFO_EXTENSION))) {
throw new ImageUploadException(trans('errors.image_upload_replace_type'));
}

Expand Down
30 changes: 21 additions & 9 deletions app/Util/CspService.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,30 @@ protected function getAllowedIframeHosts(): array

protected function getAllowedIframeSources(): array
{
$sources = config('app.iframe_sources', '');
$hosts = array_filter(explode(' ', $sources));
$sources = explode(' ', config('app.iframe_sources', ''));
$sources[] = $this->getDrawioHost();

// Extract drawing service url to allow embedding if active
return array_filter($sources);
}

/**
* Extract the host name of the configured drawio URL for use in CSP.
* Returns empty string if not in use.
*/
protected function getDrawioHost(): string
{
$drawioConfigValue = config('services.drawio');
if ($drawioConfigValue) {
$drawioSource = is_string($drawioConfigValue) ? $drawioConfigValue : 'https://embed.diagrams.net/';
$drawioSourceParsed = parse_url($drawioSource);
$drawioHost = $drawioSourceParsed['scheme'] . '://' . $drawioSourceParsed['host'];
$hosts[] = $drawioHost;
if (!$drawioConfigValue) {
return '';
}

$drawioSource = is_string($drawioConfigValue) ? $drawioConfigValue : 'https://embed.diagrams.net/';
$drawioSourceParsed = parse_url($drawioSource);
$drawioHost = $drawioSourceParsed['scheme'] . '://' . $drawioSourceParsed['host'];
if (isset($drawioSourceParsed['port'])) {
$drawioHost .= ':' . $drawioSourceParsed['port'];
}

return $hosts;
return $drawioHost;
}
}
Loading

0 comments on commit 3824e96

Please sign in to comment.