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

Patch 4.2.1 #68

Merged
merged 5 commits into from
Jun 19, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yml,yaml}]
indent_size = 2
2 changes: 1 addition & 1 deletion app/Commands/RedditFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function run(array $params = [])
$row['excerpt'] = excerpt($search, $row['match']);

// Print the header and highlighted version
CLI::write($row['kind'] . ' ' . $row['name'] . ' ' . $row['title'], 'green'); // @phpstan-ignore-line
CLI::write($row['kind'] . ' ' . $row['name'] . ' ' . $row['title'], 'green');
CLI::write(highlight_phrase($row['excerpt'], $row['match'], "\033[0;33m", "\033[0m"));

// Insert it into the database
Expand Down
7 changes: 4 additions & 3 deletions app/Config/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Config;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\FileHandler;

class App extends BaseConfig
{
Expand Down Expand Up @@ -151,7 +152,7 @@ class App extends BaseConfig
*
* @var string
*/
public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler';
public $sessionDriver = FileHandler::class;

/**
* --------------------------------------------------------------------------
Expand Down Expand Up @@ -318,7 +319,7 @@ class App extends BaseConfig
* (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$cookieSecure` must also be set.
*
* @var string
* @var string|null
*
* @deprecated use Config\Cookie::$samesite property instead.
*/
Expand Down Expand Up @@ -436,7 +437,7 @@ class App extends BaseConfig
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
* @deprecated Use `Config\Security` $samesite property instead of using this property.
* @deprecated `Config\Cookie` $samesite property is used.
*
* @var string
*/
Expand Down
15 changes: 15 additions & 0 deletions app/Config/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,18 @@
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead.
*/
define('EVENT_PRIORITY_LOW', 200);

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead.
*/
define('EVENT_PRIORITY_NORMAL', 100);

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
*/
define('EVENT_PRIORITY_HIGH', 10);
21 changes: 21 additions & 0 deletions app/Config/ContentSecurityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,25 @@ class ContentSecurityPolicy extends BaseConfig
* @var string|string[]|null
*/
public $sandbox;

/**
* Nonce tag for style
*
* @var string
*/
public $styleNonceTag = '{csp-style-nonce}';

/**
* Nonce tag for script
*
* @var string
*/
public $scriptNonceTag = '{csp-script-nonce}';

/**
* Replace nonce tag automatically
*
* @var bool
*/
public $autoNonce = true;
}
37 changes: 19 additions & 18 deletions app/Config/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Database extends Config
'DBDriver' => 'SQLite3',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'DBDebug' => true, // Whether to allow exceptions or not
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
Expand All @@ -57,23 +57,24 @@ class Database extends Config
* @var array
*/
public $tests = [
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => '',
'password' => '',
'database' => ':memory:',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => '',
'password' => '',
'database' => ':memory:',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false,
'DBDebug' => true, // Whether to allow exceptions or not
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
'foreignKeys' => true,
];

public function __construct()
Expand Down
7 changes: 6 additions & 1 deletion app/Config/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Feature extends BaseConfig
{
/**
* Enable multiple filters for a route or not
* Enable multiple filters for a route or not.
*
* If you enable this:
* - CodeIgniter\CodeIgniter::handleRequest() uses:
Expand All @@ -24,4 +24,9 @@ class Feature extends BaseConfig
* @var bool
*/
public $multipleFilters = false;

/**
* Use improved new auto routing instead of the default legacy version.
*/
public bool $autoRoutesImproved = false;
}
6 changes: 5 additions & 1 deletion app/Config/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ class Filters extends BaseConfig
* particular HTTP method (GET, POST, etc.).
*
* Example:
* 'post' => ['csrf', 'throttle']
* 'post' => ['foo', 'bar']
*
* If you use this, you should disable auto-routing because auto-routing
* permits any HTTP method to access a controller. Accessing the controller
* with a method you don’t expect could bypass the filter.
*
* @var array
*/
Expand Down
8 changes: 5 additions & 3 deletions app/Config/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Format\FormatterInterface;
use CodeIgniter\Format\JSONFormatter;
use CodeIgniter\Format\XMLFormatter;

class Format extends BaseConfig
{
Expand Down Expand Up @@ -40,9 +42,9 @@ class Format extends BaseConfig
* @var array<string, string>
*/
public $formatters = [
'application/json' => 'CodeIgniter\Format\JSONFormatter',
'application/xml' => 'CodeIgniter\Format\XMLFormatter',
'text/xml' => 'CodeIgniter\Format\XMLFormatter',
'application/json' => JSONFormatter::class,
'application/xml' => XMLFormatter::class,
'text/xml' => XMLFormatter::class,
];

/**
Expand Down
3 changes: 2 additions & 1 deletion app/Config/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Config;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Log\Handlers\FileHandler;

class Logger extends BaseConfig
{
Expand Down Expand Up @@ -83,7 +84,7 @@ class Logger extends BaseConfig
* File Handler
* --------------------------------------------------------------------
*/
'CodeIgniter\Log\Handlers\FileHandler' => [
FileHandler::class => [

// The log levels that this handler will handle.
'handles' => [
Expand Down
20 changes: 9 additions & 11 deletions app/Config/Mimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class Mimes
],
'pptx' => [
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/x-zip',
'application/zip',
],
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
Expand Down Expand Up @@ -260,6 +258,7 @@ class Mimes
'image/png',
'image/x-png',
],
'webp' => 'image/webp',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'css' => [
Expand Down Expand Up @@ -511,20 +510,19 @@ public static function guessExtensionFromType(string $type, ?string $proposedExt

$proposedExtension = trim(strtolower($proposedExtension ?? ''));

if ($proposedExtension !== '') {
if (array_key_exists($proposedExtension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposedExtension]) ? [static::$mimes[$proposedExtension]] : static::$mimes[$proposedExtension], true)) {
// The detected mime type matches with the proposed extension.
return $proposedExtension;
}

// An extension was proposed, but the media type does not match the mime type list.
return null;
if (
$proposedExtension !== ''
&& array_key_exists($proposedExtension, static::$mimes)
&& in_array($type, (array) static::$mimes[$proposedExtension], true)
) {
// The detected mime type matches with the proposed extension.
return $proposedExtension;
}

// Reverse check the mime type list if no extension was proposed.
// This search is order sensitive!
foreach (static::$mimes as $ext => $types) {
if ((is_string($types) && $types === $type) || (is_array($types) && in_array($type, $types, true))) {
if (in_array($type, (array) $types, true)) {
return $ext;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Config/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ class Publisher extends BasePublisher
*/
public $restrictions = [
ROOTPATH => '*',
FCPATH => '#\.(?css|js|map|htm?|xml|json|webmanifest|tff|eot|woff?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
];
}
10 changes: 7 additions & 3 deletions app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
if (is_file(SYSTEMPATH . 'Config/Routes.php')) {
require SYSTEMPATH . 'Config/Routes.php';
}

Expand All @@ -21,7 +21,11 @@
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
// where controller filters or CSRF protection are bypassed.
// If you don't want to define all routes, please use the Auto Routing (Improved).
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
//$routes->setAutoRoute(false);

/*
* --------------------------------------------------------------------
Expand All @@ -46,7 +50,7 @@
* You will have access to the $routes object within that file without
* needing to reload it.
*/
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
/**
* @psalm-suppress MissingFile
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Config/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Security extends BaseConfig
*
* @var string
*
* @deprecated
* @deprecated `Config\Cookie` $samesite property is used.
*/
public $samesite = 'Lax';
}
3 changes: 2 additions & 1 deletion app/Config/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Config;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Validation\CreditCardRules;
use CodeIgniter\Validation\FileRules;
use CodeIgniter\Validation\FormatRules;
use CodeIgniter\Validation\Rules;

class Validation
class Validation extends BaseConfig
{
//--------------------------------------------------------------------
// Setup
Expand Down
12 changes: 12 additions & 0 deletions app/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Config;

use CodeIgniter\Config\View as BaseView;
use CodeIgniter\View\ViewDecoratorInterface;

class View extends BaseView
{
Expand Down Expand Up @@ -41,4 +42,15 @@ class View extends BaseView
* @var array
*/
public $plugins = [];

/**
* View Decorators are class methods that will be run in sequence to
* have a chance to alter the generated output just prior to caching
* the results.
*
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
*
* @var class-string<ViewDecoratorInterface>[]
*/
public array $decorators = [];
}
2 changes: 1 addition & 1 deletion app/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* For security be sure to declare any new methods as protected or private.
*/
class BaseController extends Controller
abstract class BaseController extends Controller
{
/**
* Instance of the main Request object.
Expand Down