Skip to content

Commit 3824e96

Browse files
authored
Merge branch 'BookStackApp:release' into release
2 parents 883ea5b + d6021f4 commit 3824e96

32 files changed

+550
-452
lines changed

.github/translators.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,6 @@ Ohadp :: Hebrew
428428
cbridi :: Portuguese, Brazilian
429429
nanangsb :: Indonesian
430430
Michal Melich (michalmelich) :: Czech
431-
David (david-prv) :: German
431+
David (david-prv) :: German; German Informal
432+
Larry (lahoje) :: Swedish
433+
Marcia dos Santos (marciab80) :: Portuguese

app/Access/Oidc/OidcUserDetails.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function isFullyPopulated(bool $groupSyncActive): bool
2222
$hasEmpty = empty($this->externalId)
2323
|| empty($this->email)
2424
|| empty($this->name)
25-
|| ($groupSyncActive && empty($this->groups));
25+
|| ($groupSyncActive && $this->groups === null);
2626

2727
return !$hasEmpty;
2828
}
@@ -57,15 +57,15 @@ protected static function getUserDisplayName(string $displayNameClaims, Provides
5757
return implode(' ', $displayName);
5858
}
5959

60-
protected static function getUserGroups(string $groupsClaim, ProvidesClaims $token): array
60+
protected static function getUserGroups(string $groupsClaim, ProvidesClaims $token): ?array
6161
{
6262
if (empty($groupsClaim)) {
63-
return [];
63+
return null;
6464
}
6565

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

7171
return array_values(array_filter($groupsList, function ($val) {

app/Uploads/ImageRepo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function updateImageDetails(Image $image, $updateDetails): Image
166166
*/
167167
public function updateImageFile(Image $image, UploadedFile $file): void
168168
{
169-
if ($file->getClientOriginalExtension() !== pathinfo($image->path, PATHINFO_EXTENSION)) {
169+
if (strtolower($file->getClientOriginalExtension()) !== strtolower(pathinfo($image->path, PATHINFO_EXTENSION))) {
170170
throw new ImageUploadException(trans('errors.image_upload_replace_type'));
171171
}
172172

app/Util/CspService.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,30 @@ protected function getAllowedIframeHosts(): array
133133

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

139-
// Extract drawing service url to allow embedding if active
139+
return array_filter($sources);
140+
}
141+
142+
/**
143+
* Extract the host name of the configured drawio URL for use in CSP.
144+
* Returns empty string if not in use.
145+
*/
146+
protected function getDrawioHost(): string
147+
{
140148
$drawioConfigValue = config('services.drawio');
141-
if ($drawioConfigValue) {
142-
$drawioSource = is_string($drawioConfigValue) ? $drawioConfigValue : 'https://embed.diagrams.net/';
143-
$drawioSourceParsed = parse_url($drawioSource);
144-
$drawioHost = $drawioSourceParsed['scheme'] . '://' . $drawioSourceParsed['host'];
145-
$hosts[] = $drawioHost;
149+
if (!$drawioConfigValue) {
150+
return '';
151+
}
152+
153+
$drawioSource = is_string($drawioConfigValue) ? $drawioConfigValue : 'https://embed.diagrams.net/';
154+
$drawioSourceParsed = parse_url($drawioSource);
155+
$drawioHost = $drawioSourceParsed['scheme'] . '://' . $drawioSourceParsed['host'];
156+
if (isset($drawioSourceParsed['port'])) {
157+
$drawioHost .= ':' . $drawioSourceParsed['port'];
146158
}
147159

148-
return $hosts;
160+
return $drawioHost;
149161
}
150162
}

0 commit comments

Comments
 (0)