Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors: sanitize output #2820

Merged
merged 1 commit into from
Dec 2, 2024
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
4 changes: 2 additions & 2 deletions lib/Factory/MediaFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -183,7 +183,7 @@ public function queueDownload($name, $uri, $expiry, $requestOptions = [])
$media->enableStat = $requestOptions['enableStat'];
$media->folderId = $requestOptions['folderId'];
$media->permissionsFolderId = $requestOptions['permissionsFolderId'];
$media->apiRef = $requestOptions['apiRef'];
$media->apiRef = $requestOptions['apiRef'] ?? null;
}

$this->getLog()->debug('Queue download of: ' . $uri . ', current mediaId for this download is '
Expand Down
6 changes: 3 additions & 3 deletions lib/Middleware/Handlers.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand Down Expand Up @@ -53,7 +53,7 @@
*/
public static function jsonErrorHandler($container)
{
return function (Request $request, \Throwable $exception, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails) use ($container) {

Check warning on line 56 in lib/Middleware/Handlers.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 151 characters
self::rollbackAndCloseStore($container);
self::writeLog($request, $logErrors, $logErrorDetails, $exception, $container);

Expand Down Expand Up @@ -92,7 +92,7 @@
*/
public static function webErrorHandler($container)
{
return function (Request $request, \Throwable $exception, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails) use ($container) {

Check warning on line 95 in lib/Middleware/Handlers.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 151 characters
self::rollbackAndCloseStore($container);
self::writeLog($request, $logErrors, $logErrorDetails, $exception, $container);

Expand Down Expand Up @@ -122,8 +122,8 @@
// Prepend our theme files to the view path
// Does this theme provide an alternative view path?
if ($configService->getThemeConfig('view_path') != '') {
$twig->getLoader()->prependPath(Str::replaceFirst('..', PROJECT_ROOT,

Check failure on line 125 in lib/Middleware/Handlers.php

View workflow job for this annotation

GitHub Actions / phpcs

Opening parenthesis of a multi-line function call must be the last content on the line

Check failure on line 125 in lib/Middleware/Handlers.php

View workflow job for this annotation

GitHub Actions / phpcs

Only one argument is allowed per line in a multi-line function call
$configService->getThemeConfig('view_path')));

Check failure on line 126 in lib/Middleware/Handlers.php

View workflow job for this annotation

GitHub Actions / phpcs

Multi-line function call not indented correctly; expected 16 spaces but found 20

Check failure on line 126 in lib/Middleware/Handlers.php

View workflow job for this annotation

GitHub Actions / phpcs

Closing parenthesis of a multi-line function call must be on a line by itself
}

// We have translated error/not-found
Expand Down Expand Up @@ -151,7 +151,7 @@
} else {
// Make a friendly message
if ($displayErrorDetails || $exception instanceof GeneralException) {
$message = $exception->getMessage();
$message = htmlspecialchars($exception->getMessage());
} else {
$message = __('Unexpected Error, please contact support.');
}
Expand Down Expand Up @@ -213,7 +213,7 @@
*/
public static function testErrorHandler($container)
{
return function (Request $request, \Throwable $exception, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails) use ($container) {

Check warning on line 216 in lib/Middleware/Handlers.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 151 characters
self::rollbackAndCloseStore($container);

$nyholmFactory = new Psr17Factory();
Expand Down Expand Up @@ -264,7 +264,7 @@
* @param \Throwable $exception
* @param \Psr\Container\ContainerInterface $container
*/
private static function writeLog($request, bool $logErrors, bool $logErrorDetails, \Throwable $exception, $container)

Check warning on line 267 in lib/Middleware/Handlers.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 121 characters
{
/** @var \Psr\Log\LoggerInterface $logger */
$logger = $container->get('logger');
Expand Down
Loading