Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Exception/PadFileLockRetryExhaustedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
private int $retryAttempts,
private LockedException $lockedException,
) {
parent::__construct($lockedException->getMessage(), (int)$lockedException->getCode(), $lockedException);
parent::__construct($lockedException->getMessage(), $lockedException->getCode(), $lockedException);
}

public function getRetryAttempts(): int {
Expand Down
6 changes: 3 additions & 3 deletions lib/Listeners/CSPListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ private function normalizeExternalAllowlistEntry(string $entry): ?string {
if (!is_array($parts)) {
return null;
}
$scheme = strtolower((string)($parts['scheme'] ?? ''));
$host = strtolower((string)($parts['host'] ?? ''));
$port = isset($parts['port']) ? (int)$parts['port'] : 443;
$scheme = strtolower($parts['scheme'] ?? '');
$host = strtolower($parts['host'] ?? '');
$port = isset($parts['port']) ? $parts['port'] : 443;
if ($scheme !== 'https' || $host === '' || $port <= 0 || $port > 65535) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/AdminSettingsValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function normalizeEtherpadApiHost(string $rawHost, string $fallbackPubli
throw new AdminValidationException('etherpad_api_host', $this->l10n->t('Etherpad API URL must not include query or fragment.'));
}

$scheme = strtolower((string)$parts['scheme']);
$scheme = strtolower($parts['scheme']);
if (!in_array($scheme, ['http', 'https'], true)) {
throw new AdminValidationException('etherpad_api_host', $this->l10n->t('Etherpad API URL must use http or https.'));
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/AllowlistNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ private function normalizeUrlEntry(string $entry): string {
);
}

$scheme = strtolower((string)($parts['scheme'] ?? ''));
$host = strtolower((string)($parts['host'] ?? ''));
$port = isset($parts['port']) ? (int)$parts['port'] : 443;
$path = (string)($parts['path'] ?? '');
$scheme = strtolower($parts['scheme'] ?? '');
$host = strtolower($parts['host'] ?? '');
$port = isset($parts['port']) ? $parts['port'] : 443;
$path = $parts['path'] ?? '';

if ($scheme !== 'https' || $host === '' || $port <= 0 || $port > 65535 || ($path !== '' && $path !== '/')
|| isset($parts['user']) || isset($parts['pass']) || isset($parts['query']) || isset($parts['fragment'])
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/EtherpadClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ public function normalizeOrigin(string $url): string {
if ($parts === false || empty($parts['scheme']) || empty($parts['host'])) {
return '';
}
$scheme = strtolower((string)$parts['scheme']);
$host = strtolower((string)$parts['host']);
$port = isset($parts['port']) ? (int)$parts['port'] : null;
$scheme = strtolower($parts['scheme']);
$host = strtolower($parts['host']);
$port = isset($parts['port']) ? $parts['port'] : null;
$isDefaultPort = ($scheme === 'https' && $port === 443) || ($scheme === 'http' && $port === 80);
if ($port === null || $isDefaultPort) {
return $scheme . '://' . $host;
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/EtherpadHealthCheckService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function check(ValidatedAdminSettings $settings): HealthCheckResult {
// path leaks the literal '{detail}' through to consumers in
// some catalog setups. Doing the substitution here removes that
// surface area.
$template = (string)$this->l10n->t('Etherpad connection test failed: {detail}');
$template = $this->l10n->t('Etherpad connection test failed: {detail}');
throw new AdminHealthCheckException(
str_replace('{detail}', $detail, $template),
0,
Expand Down
18 changes: 9 additions & 9 deletions lib/Service/ExternalPadExportFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ private function normalizeAllowlistOrigin(string $entry): string {
if (!is_array($parts)) {
return '';
}
$scheme = strtolower((string)($parts['scheme'] ?? ''));
$host = strtolower((string)($parts['host'] ?? ''));
$port = isset($parts['port']) ? (int)$parts['port'] : 443;
$scheme = strtolower($parts['scheme'] ?? '');
$host = strtolower($parts['host'] ?? '');
$port = isset($parts['port']) ? $parts['port'] : 443;
if ($scheme !== 'https' || $host === '' || $port <= 0 || $port > 65535) {
return '';
}
Expand All @@ -308,10 +308,10 @@ private function parsePublicPadUrl(string $padUrl): array {
throw new EtherpadClientException('Public pad URL must not contain credentials.');
}

$scheme = strtolower((string)($parts['scheme'] ?? ''));
$host = strtolower((string)($parts['host'] ?? ''));
$port = isset($parts['port']) ? (int)$parts['port'] : 443;
$path = (string)($parts['path'] ?? '');
$scheme = strtolower($parts['scheme'] ?? '');
$host = strtolower($parts['host'] ?? '');
$port = isset($parts['port']) ? $parts['port'] : 443;
$path = $parts['path'] ?? '';
// `+` is literal in URL path segments — only query/form bodies treat
// it as a space. Using urldecode here turned `/p/team+pad` into
// pad-id `team pad`, then re-encoded to `/p/team%20pad` at fetch
Expand All @@ -325,8 +325,8 @@ private function parsePublicPadUrl(string $padUrl): array {
throw new EtherpadClientException('Public pad URL must match /p/{padId}.');
}

$basePath = rtrim((string)$matches[1], '/');
$padId = trim((string)$matches[2]);
$basePath = rtrim($matches[1], '/');
$padId = trim($matches[2]);
if ($padId === '') {
throw new EtherpadClientException('Invalid public pad URL.');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/LifecycleService.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function handleTrash(File $file): array {
if ($this->isTestFaultActive(self::TEST_FAULT_TRASH_WRITE_FAIL)) {
throw new \RuntimeException('Injected test fault: trash_write_fail');
}
$file->putContent((string)$updatedContent);
$file->putContent($updatedContent);
$snapshotPersisted = true;
} catch (LockedException $e) {
// Trash operation can hold a lock on the file node; do not block state transition/deletion.
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/PadFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function parseLegacyOwnpadShortcut(string $content): ?array {
return null;
}

$url = trim((string)$matches[1]);
$url = trim($matches[1]);
if ($url === '' || preg_match('#^https?://#i', $url) !== 1) {
return null;
}
Expand All @@ -118,7 +118,7 @@ public function parseLegacyOwnpadShortcut(string $content): ?array {
if (preg_match('~/p/([^/?#]+)$~', $decodedPath, $padMatches) !== 1) {
return null;
}
$padId = trim((string)$padMatches[1]);
$padId = trim($padMatches[1]);
if ($padId === '') {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/PadOpenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ private function openNode(string $uid, string $displayName, File $node, string $
throw new \RuntimeException('Could not resolve file ID.');
}

$pad = $this->padFileService->readPad((string)$content);
$pad = $this->padFileService->readPad($content);
$padId = $pad->padId;
$accessMode = $pad->accessMode;
$padUrl = $pad->padUrl;
$isExternal = $pad->isExternal;
$snapshot = $isExternal
? $this->snapshotExtractor->extract((string)$content)
? $this->snapshotExtractor->extract($content)
: new SnapshotPayload('', '');
if (!$isExternal) {
$this->bindingService->assertConsistentMapping($fileId, $padId, $accessMode);
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/TrustedEmbedOriginsNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@ private function normalizeOrigin(string $entry, bool $throwOnInvalid): string {
if (!is_array($parts) || !isset($parts['scheme'], $parts['host'])) {
return $this->invalid($throwOnInvalid, 'Trusted embed origins must be absolute origins: {origin}', $entry);
}
if (isset($parts['path']) && trim((string)$parts['path'], '/') !== '') {
if (isset($parts['path']) && trim($parts['path'], '/') !== '') {
return $this->invalid($throwOnInvalid, 'Trusted embed origins must not include a path: {origin}', $entry);
}
if (isset($parts['query']) || isset($parts['fragment']) || isset($parts['user']) || isset($parts['pass'])) {
return $this->invalid($throwOnInvalid, 'Trusted embed origins must not include credentials, query, or fragment: {origin}', $entry);
}

$scheme = strtolower((string)$parts['scheme']);
$scheme = strtolower($parts['scheme']);
if ($scheme !== 'https') {
return $this->invalid($throwOnInvalid, 'Trusted embed origins must use https: {origin}', $entry);
}

$host = strtolower((string)$parts['host']);
$host = strtolower($parts['host']);
if (str_contains($host, ':') && !str_starts_with($host, '[')) {
$host = '[' . $host . ']';
}
$origin = $scheme . '://' . $host;
if (isset($parts['port'])) {
$port = (int)$parts['port'];
$port = $parts['port'];
if ($port < 1 || $port > 65535) {
return $this->invalid($throwOnInvalid, 'Trusted embed origins must use a valid TCP port: {origin}', $entry);
}
Expand Down
Loading