diff --git a/app/Config/App.php b/app/Config/App.php
index ffe0c6c..2da765f 100644
--- a/app/Config/App.php
+++ b/app/Config/App.php
@@ -21,7 +21,7 @@
| environments.
|
*/
- public $baseURL = 'http://localhost:8080';
+ public $baseURL = 'http://localhost:8080/';
/*
|--------------------------------------------------------------------------
diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php
index af0e201..6a673d3 100644
--- a/app/Config/Autoload.php
+++ b/app/Config/Autoload.php
@@ -50,9 +50,9 @@
* `];
*/
$psr4 = [
- 'Config' => APPPATH . 'Config',
- APP_NAMESPACE => APPPATH, // For custom namespace
'App' => APPPATH, // To ensure filters, etc still found,
+ APP_NAMESPACE => APPPATH, // For custom namespace
+ 'Config' => APPPATH . 'Config',
];
/**
diff --git a/app/Config/Database.php b/app/Config/Database.php
index f3fe66c..b31541a 100644
--- a/app/Config/Database.php
+++ b/app/Config/Database.php
@@ -62,9 +62,9 @@
'hostname' => '127.0.0.1',
'username' => '',
'password' => '',
- 'database' => '',
- 'DBDriver' => '',
- 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE.
+ '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'),
'cacheOn' => false,
diff --git a/app/Config/Email.php b/app/Config/Email.php
index d580c53..d9ca142 100644
--- a/app/Config/Email.php
+++ b/app/Config/Email.php
@@ -1,7 +1,9 @@
WRITEPATH . 'logs/',
-
- /*
- * The default filename extension for log files. The default 'php' allows for
- * protecting the log files via basic scripting, when they are to be stored
- * under a publicly accessible directory.
+ * The default filename extension for log files.
+ * An extension of 'php' allows for protecting the log files via basic
+ * scripting, when they are to be stored under a publicly accessible directory.
*
- * Note: Leaving it blank will default to 'php'.
+ * Note: Leaving it blank will default to 'log'.
*/
- 'fileExtension' => 'php',
+ 'fileExtension' => '',
/*
* The file system permissions to be applied on newly created log files.
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 8e13664..4832736 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -1,22 +1,5 @@
defaultNamespace()
- *
- * Modifies the namespace that is added to a controller if it doesn't
- * already have one. By default this is the global namespace (\).
- *
- * $routes->defaultController()
- *
- * Changes the name of the class used as a controller when the route
- * points to a folder instead of a class.
- *
- * $routes->defaultMethod()
- *
- * Assigns the method inside the controller that is ran when the
- * Router is unable to determine the appropriate method to run.
- *
- * $routes->setAutoRoute()
- *
- * Determines whether the Router will attempt to match URIs to
- * Controllers when no specific route has been defined. If false,
- * only routes that have been defined here will be available.
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
diff --git a/contributing.md b/contributing.md
index 09dff38..abeea35 100644
--- a/contributing.md
+++ b/contributing.md
@@ -3,77 +3,90 @@
## Contributions
-We expect all contributions to conform to our style guide, be commented (inside the PHP source files),
-be documented (in the user guide), and unit tested (in the test folder).
+We expect all contributions to conform to our [style guide](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/styleguide.rst), be commented (inside the PHP source files),
+be documented (in the [user guide](https://codeigniter4.github.io/userguide/)), and unit tested (in the [test folder](https://github.com/codeigniter4/CodeIgniter4/tree/develop/tests)).
There is a [Contributing to CodeIgniter](./contributing/README.rst) section in the repository which describes the contribution process; this page is an overview.
+The [Open Source Guide](https://opensource.guide/) is a good first read for those new to contributing to open source!
## Issues
-Issues are a quick way to point out a bug. If you find a bug or documentation error in CodeIgniter then please check a few things first:
+Issues are a quick way to point out a bug. If you find a bug or documentation error in CodeIgniter then please make sure that:
-1. There is not already an open Issue
-2. The issue has already been fixed (check the develop branch, or look for closed Issues)
-3. Is it something really obvious that you can fix yourself?
+1. There is not already an open [Issue](https://github.com/codeigniter4/CodeIgniter4/issues)
+2. The Issue has not already been fixed (check the develop branch or look for [closed Issues](https://github.com/codeigniter4/CodeIgniter4/issues?q=is%3Aissue+is%3Aclosed))
+3. It's not something really obvious that you can fix yourself
-Reporting issues is helpful but an even [better approach](./contributing/workflow.rst) is to send a Pull Request, which is done by "Forking" the main repository and committing to your own copy. This will require you to use the version control system called Git.
+Reporting Issues is helpful, but an even [better approach](./contributing/workflow.rst) is to send a [Pull Request](https://help.github.com/en/articles/creating-a-pull-request), which is done by [Forking](https://help.github.com/en/articles/fork-a-repo) the main repository and making a [Commit](https://help.github.com/en/desktop/contributing-to-projects/committing-and-reviewing-changes-to-your-project) to your own copy of the project. This will require you to use the version control system called [Git](https://git-scm.com/).
## Guidelines
-Before we look into how, here are the guidelines. If your Pull Requests fail
-to pass these guidelines it will be declined and you will need to re-submit
+Before we look into how to contribute to CodeIgniter4, here are some guidelines. If your Pull Requests fail
+to pass these guidelines, they will be declined, and you will need to re-submit
when you’ve made the changes. This might sound a bit tough, but it is required
-for us to maintain quality of the code-base.
+for us to maintain quality of the codebase.
### PHP Style
All code must meet the [Style Guide](./contributing/styleguide.rst).
-This makes certain that all code is the same format as the existing code and means it will be as readable as possible.
+This makes certain that all submitted code is of the same format as the existing code and ensures that the codebase will be as readable as possible.
### Documentation
-If you change anything that requires a change to documentation then you will need to add it. New classes, methods, parameters, changing default values, etc are all things that will require a change to documentation. The change-log must also be updated for every change. Also PHPDoc blocks must be maintained.
+If you change anything that requires a change to documentation, then you will need to add to the documentation. New classes, methods, parameters, changing default values, etc. are all changes that require a change to documentation. Also, the [changelog](https://codeigniter4.github.io/CodeIgniter4/changelogs/index.html) must be updated for every change, and [PHPDoc](https://github.com/codeigniter4/CodeIgniter4/blob/develop/phpdoc.dist.xml) blocks must be maintained.
### Compatibility
-CodeIgniter4 requires PHP 7.2.
+CodeIgniter4 requires [PHP 7.2](https://php.net/releases/7_2_0.php).
### Branching
-CodeIgniter4 uses the [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/) branching model which requires all pull requests to be sent to the "develop" branch. This is
-where the next planned version will be developed. The "master" branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g: an emergency security patch) can be applied to master to create a new version, without worrying about other features holding it up. For this reason all commits need to be made to "develop" and any sent to "master" will be closed automatically. If you have multiple changes to submit, please place all changes into their own branch on your fork.
+CodeIgniter4 uses the [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/) branching model which requires all
+Pull Requests to be sent to the "develop" branch; this is where the next planned version will be developed.
+The "master" branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g. an
+emergency security patch) can be applied to the "master" branch to create a new version, without worrying
+about other features holding it up. For this reason, all commits need to be made to the "develop" branch,
+and any sent to the "master" branch will be closed automatically. If you have multiple changes to submit,
+please place all changes into their own branch on your fork.
-One thing at a time: A pull request should only contain one change. That does not mean only one commit, but one change - however many commits it took. The reason for this is that if you change X and Y but send a pull request for both at the same time, we might really want X but disagree with Y, meaning we cannot merge the request. Using the Git-Flow branching model you can create new branches for both of these features and send two requests.
+**One thing at a time:** A pull request should only contain one change. That does not mean only one commit,
+but one change - however many commits it took. The reason for this is that if you change X and Y,
+but send a pull request for both at the same time, we might really want X but disagree with Y,
+meaning we cannot merge the request. Using the Git-Flow branching model you can create new
+branches for both of these features and send two requests.
+
+A reminder: **please use separate branches for each of your PRs** - it will make it easier for you to keep changes separate from
+each other and from whatever else you are doing with your repository!
### Signing
-You must [GPG-sign](./contributing/signing.rst) your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open source project. This is *not* just a "signed-off-by" commit, but instead a digitally signed one.
+You must [GPG-sign](./contributing/signing.rst) your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open source project. This is *not* just a "signed-off-by" commit, but instead, a digitally signed one.
## How-to Guide
The best way to contribute is to fork the CodeIgniter4 repository, and "clone" that to your development area. That sounds like some jargon, but "forking" on GitHub means "making a copy of that repo to your account" and "cloning" means "copying that code to your environment so you can work on it".
-1. Set up Git (Windows, Mac & Linux)
-2. Go to the CodeIgniter4 repo
-3. Fork it (to your Github account)
-4. Clone your CodeIgniter repo: git@github.com:\' . esc(print_r($value, true)) . '
';
}
}
@@ -153,18 +153,18 @@
$value = 'binary data';
}
- $data['vars']['session'][esc($key)] = is_string($value) ? esc($value) : print_r($value, true);
+ $data['vars']['session'][esc($key)] = is_string($value) ? esc($value) : '' . esc(print_r($value, true)) . '
';
}
}
foreach ($request->getGet() as $name => $value)
{
- $data['vars']['get'][esc($name)] = is_array($value) ? esc(print_r($value, true)) : esc($value);
+ $data['vars']['get'][esc($name)] = is_array($value) ? '' . esc(print_r($value, true)) . '
' : esc($value);
}
foreach ($request->getPost() as $name => $value)
{
- $data['vars']['post'][esc($name)] = is_array($value) ? esc(print_r($value, true)) : esc($value);
+ $data['vars']['post'][esc($name)] = is_array($value) ? '' . esc(print_r($value, true)) . '
' : esc($value);
}
foreach ($request->getHeaders() as $header => $value)
@@ -375,7 +375,7 @@
// for this response
if ($request->isAJAX() || strpos($format, 'html') === false)
{
- $response->setHeader('Debugbar-Time', $time)
+ $response->setHeader('Debugbar-Time', "$time")
->setHeader('Debugbar-Link', site_url("?debugbar_time={$time}"))
->getBody();
@@ -390,10 +390,10 @@
. ''
. PHP_EOL;
- if (strpos($response->getBody(), '
') !== false) + if (strpos($response->getBody(), '
') !== false) { $response->setBody( - str_replace('', $script . '', $response->getBody()) + str_replace('
', $script . '
', $response->getBody()) ); return; diff --git a/system/Debug/Toolbar/Collectors/BaseCollector.php b/system/Debug/Toolbar/Collectors/BaseCollector.php index 6fe76f9..dade0ab 100644 --- a/system/Debug/Toolbar/Collectors/BaseCollector.php +++ b/system/Debug/Toolbar/Collectors/BaseCollector.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar/Collectors/Config.php b/system/Debug/Toolbar/Collectors/Config.php index f6839b4..1ae809c 100644 --- a/system/Debug/Toolbar/Collectors/Config.php +++ b/system/Debug/Toolbar/Collectors/Config.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index 5b03d05..00aa740 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -175,6 +175,8 @@ 'WHERE', 'AND', 'LEFT JOIN', + 'RIGHT JOIN', + 'JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', diff --git a/system/Debug/Toolbar/Collectors/Events.php b/system/Debug/Toolbar/Collectors/Events.php index c574507..285d87d 100644 --- a/system/Debug/Toolbar/Collectors/Events.php +++ b/system/Debug/Toolbar/Collectors/Events.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; use CodeIgniter\View\RendererInterface; /** @@ -94,7 +94,7 @@ */ public function __construct() { - $this->viewer = Services::renderer(null, true); + $this->viewer = Services::renderer(); } //-------------------------------------------------------------------- diff --git a/system/Debug/Toolbar/Collectors/Files.php b/system/Debug/Toolbar/Collectors/Files.php index 78c8b51..36b0132 100644 --- a/system/Debug/Toolbar/Collectors/Files.php +++ b/system/Debug/Toolbar/Collectors/Files.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar/Collectors/History.php b/system/Debug/Toolbar/Collectors/History.php index 90152f2..3112e07 100644 --- a/system/Debug/Toolbar/Collectors/History.php +++ b/system/Debug/Toolbar/Collectors/History.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Debug/Toolbar/Collectors/Logs.php b/system/Debug/Toolbar/Collectors/Logs.php index b310b60..ed279c7 100644 --- a/system/Debug/Toolbar/Collectors/Logs.php +++ b/system/Debug/Toolbar/Collectors/Logs.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; /** * Loags collector diff --git a/system/Debug/Toolbar/Collectors/Routes.php b/system/Debug/Toolbar/Collectors/Routes.php index 4891a15..2a80c55 100644 --- a/system/Debug/Toolbar/Collectors/Routes.php +++ b/system/Debug/Toolbar/Collectors/Routes.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -38,7 +38,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; /** * Routes collector diff --git a/system/Debug/Toolbar/Collectors/Timers.php b/system/Debug/Toolbar/Collectors/Timers.php index ea5f5e3..d6168c6 100644 --- a/system/Debug/Toolbar/Collectors/Timers.php +++ b/system/Debug/Toolbar/Collectors/Timers.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; /** * Timers collector diff --git a/system/Debug/Toolbar/Collectors/Views.php b/system/Debug/Toolbar/Collectors/Views.php index 1f92507..8bcec56 100644 --- a/system/Debug/Toolbar/Collectors/Views.php +++ b/system/Debug/Toolbar/Collectors/Views.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -39,7 +39,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\Config\Services; +use Config\Services; use CodeIgniter\View\RendererInterface; /** diff --git a/system/Debug/Toolbar/Views/toolbar.css b/system/Debug/Toolbar/Views/toolbar.css index 826c20c..f53b8fe 100644 --- a/system/Debug/Toolbar/Views/toolbar.css +++ b/system/Debug/Toolbar/Views/toolbar.css @@ -37,6 +37,10 @@ z-index: 10000; } +#debug-bar pre { + line-height: normal; +} + #debug-bar h1, #debug-bar h2, #debug-bar h3 { diff --git a/system/Debug/Toolbar/Views/toolbarloader.js.php b/system/Debug/Toolbar/Views/toolbarloader.js.php index 236ea01..4ecdeeb 100644 --- a/system/Debug/Toolbar/Views/toolbarloader.js.php +++ b/system/Debug/Toolbar/Views/toolbarloader.js.php @@ -56,7 +56,7 @@ } }; - xhttp.open("GET", url + "/?debugbar_time=" + time, true); + xhttp.open("GET", url + "?debugbar_time=" + time, true); xhttp.send(); } diff --git a/system/Email/Email.php b/system/Email/Email.php index 42d4b22..ee0e014 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014 - 2019, British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,6 @@ namespace CodeIgniter\Email; use Config\Mimes; -use Psr\Log\LoggerAwareTrait; /** * CodeIgniter Email Class @@ -55,7 +54,6 @@ */ class Email { - use LoggerAwareTrait; /** * @var string */ @@ -355,12 +353,6 @@ * @var boolean */ protected static $func_overload; - /** - * Logger instance to record error messages and awarnings. - * - * @var \PSR\Log\LoggerInterface - */ - protected $logger; //-------------------------------------------------------------------- /** * Constructor - Sets Email Preferences @@ -373,7 +365,6 @@ { $this->initialize($config); isset(static::$func_overload) || static::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload')); - log_message('info', 'Email Class Initialized'); } //-------------------------------------------------------------------- /** @@ -1498,7 +1489,7 @@ $output = '=?' . $this->charset . '?Q?'; for ($i = 0, $length = static::strlen($output); $i < $chars; $i ++) { - $chr = ($this->charset === 'UTF-8' && ICONV_ENABLED === true) ? '=' . implode('=', str_split(strtoupper(bin2hex(iconv_substr($str, $i, 1, $this->charset))), 2)) : '=' . strtoupper(bin2hex($str[$i])); + $chr = ($this->charset === 'UTF-8' && extension_loaded('iconv')) ? '=' . implode('=', str_split(strtoupper(bin2hex(iconv_substr($str, $i, 1, $this->charset))), 2)) : '=' . strtoupper(bin2hex($str[$i])); // RFC 2045 sets a limit of 76 characters per line. // We'll append ?= to the end of each line though. if ($length + ($l = static::strlen($chr)) > 74) @@ -1652,7 +1643,7 @@ catch (\ErrorException $e) { $success = false; - $this->logger->error('Email: ' . $method . ' throwed ' . $e->getMessage()); + log_message('error', 'Email: ' . $method . ' throwed ' . $e->getMessage()); } if (! $success) { @@ -1801,7 +1792,7 @@ } // perform dot transformation on any lines that begin with a dot $this->sendData($this->headerStr . preg_replace('/^\./m', '..$1', $this->finalBody)); - $this->sendData('.'); + $this->sendData($this->newline . '.'); $reply = $this->getSMTPData(); $this->setErrorMessage($reply); $this->SMTPEnd(); diff --git a/system/Encryption/EncrypterInterface.php b/system/Encryption/EncrypterInterface.php index 3a3ff7c..4b008ad 100644 --- a/system/Encryption/EncrypterInterface.php +++ b/system/Encryption/EncrypterInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2017 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/system/Encryption/Encryption.php b/system/Encryption/Encryption.php index 16f15f8..1f047f6 100644 --- a/system/Encryption/Encryption.php +++ b/system/Encryption/Encryption.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2017 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,7 +41,7 @@ use Config\Encryption as EncryptionConfig; use CodeIgniter\Encryption\Exceptions\EncryptionException; use CodeIgniter\Config\BaseConfig; -use CodeIgniter\Config\Services; +use Config\Services; /** * CodeIgniter Encryption Manager diff --git a/system/Encryption/Handlers/BaseHandler.php b/system/Encryption/Handlers/BaseHandler.php index 1efd401..62eb6b1 100644 --- a/system/Encryption/Handlers/BaseHandler.php +++ b/system/Encryption/Handlers/BaseHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2017 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/system/Encryption/Handlers/OpenSSLHandler.php b/system/Encryption/Handlers/OpenSSLHandler.php index ddaa8cb..72b6023 100644 --- a/system/Encryption/Handlers/OpenSSLHandler.php +++ b/system/Encryption/Handlers/OpenSSLHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2017 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/system/Entity.php b/system/Entity.php index 63a984e..94153d0 100644 --- a/system/Entity.php +++ b/system/Entity.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -313,7 +313,7 @@ $result = $this->mutateDate($result); } // Or cast it as something? - else if ($this->_cast && isset($this->casts[$key]) && ! empty($this->casts[$key])) + else if ($this->_cast && ! empty($this->casts[$key])) { $result = $this->castAs($result, $this->casts[$key]); } @@ -471,7 +471,7 @@ return $key; } - if (isset($this->datamap[$key]) && ! empty($this->datamap[$key])) + if (! empty($this->datamap[$key])) { return $this->datamap[$key]; } @@ -602,7 +602,7 @@ $tmp = ! is_null($value) ? ($asArray ? [] : new \stdClass) : null; if (function_exists('json_decode')) { - if ((is_string($value) && strlen($value) > 1 && in_array($value{0}, ['[', '{', '"'])) || is_numeric($value)) + if ((is_string($value) && strlen($value) > 1 && in_array($value[0], ['[', '{', '"'])) || is_numeric($value)) { $tmp = json_decode($value, $asArray); diff --git a/system/Events/Events.php b/system/Events/Events.php index ae1f69a..c616256 100644 --- a/system/Events/Events.php +++ b/system/Events/Events.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Files/File.php b/system/Files/File.php index 69a5a4b..15ff417 100644 --- a/system/Files/File.php +++ b/system/Files/File.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/CSRF.php b/system/Filters/CSRF.php index 193911f..1f0bcf8 100644 --- a/system/Filters/CSRF.php +++ b/system/Filters/CSRF.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/DebugToolbar.php b/system/Filters/DebugToolbar.php index 78e8653..465ca3e 100644 --- a/system/Filters/DebugToolbar.php +++ b/system/Filters/DebugToolbar.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/FilterInterface.php b/system/Filters/FilterInterface.php index 97bf806..d58be9e 100644 --- a/system/Filters/FilterInterface.php +++ b/system/Filters/FilterInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index b9832e9..853e135 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Filters/Honeypot.php b/system/Filters/Honeypot.php index 4faffd6..aea08c3 100644 --- a/system/Filters/Honeypot.php +++ b/system/Filters/Honeypot.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Format/FormatterInterface.php b/system/Format/FormatterInterface.php index c50be49..17bc693 100644 --- a/system/Format/FormatterInterface.php +++ b/system/Format/FormatterInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Format/JSONFormatter.php b/system/Format/JSONFormatter.php index 6beb88d..50caf39 100644 --- a/system/Format/JSONFormatter.php +++ b/system/Format/JSONFormatter.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Format/XMLFormatter.php b/system/Format/XMLFormatter.php index d45942c..3e262d6 100644 --- a/system/Format/XMLFormatter.php +++ b/system/Format/XMLFormatter.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/CLIRequest.php b/system/HTTP/CLIRequest.php index 28b6616..f9c4838 100644 --- a/system/HTTP/CLIRequest.php +++ b/system/HTTP/CLIRequest.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index ddf1cbb..c5506ac 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/ContentSecurityPolicy.php b/system/HTTP/ContentSecurityPolicy.php index ebac8cb..713312f 100644 --- a/system/HTTP/ContentSecurityPolicy.php +++ b/system/HTTP/ContentSecurityPolicy.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php index f394543..080f6b2 100644 --- a/system/HTTP/DownloadResponse.php +++ b/system/HTTP/DownloadResponse.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Exceptions/HTTPException.php b/system/HTTP/Exceptions/HTTPException.php index dc9f48e..5aa4895 100644 --- a/system/HTTP/Exceptions/HTTPException.php +++ b/system/HTTP/Exceptions/HTTPException.php @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Files/FileCollection.php b/system/HTTP/Files/FileCollection.php index 95f51cb..567ddf7 100644 --- a/system/HTTP/Files/FileCollection.php +++ b/system/HTTP/Files/FileCollection.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -310,7 +310,7 @@ */ protected function getValueDotNotationSyntax(array $index, array $value) { - if (is_array($index) && ! empty($index)) + if (! empty($index)) { $current_index = array_shift($index); } diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php index d7ff326..1826a7a 100644 --- a/system/HTTP/Files/UploadedFile.php +++ b/system/HTTP/Files/UploadedFile.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Files/UploadedFileInterface.php b/system/HTTP/Files/UploadedFileInterface.php index 7aa5aaa..64d74ad 100644 --- a/system/HTTP/Files/UploadedFileInterface.php +++ b/system/HTTP/Files/UploadedFileInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Header.php b/system/HTTP/Header.php index ff92ffa..0e75fa2 100644 --- a/system/HTTP/Header.php +++ b/system/HTTP/Header.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 51fc61f..0b363cd 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -43,7 +43,7 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\HTTP\Files\FileCollection; use CodeIgniter\HTTP\Files\UploadedFile; -use CodeIgniter\Config\Services; +use Config\Services; /** * Class IncomingRequest @@ -174,6 +174,11 @@ $this->populateHeaders(); + // Get our current URI. + // NOTE: This WILL NOT match the actual URL in the browser since for + // everything this cares about (and the router, etc) is the portion + // AFTER the script name. So, if hosted in a sub-folder this will + // appear different than actual URL. If you need that, use current_url(). $this->uri = $uri; $this->detectURI($config->uriProtocol, $config->baseURL); @@ -604,14 +609,10 @@ // baseURL, so let's help them out. $baseURL = ! empty($baseURL) ? rtrim($baseURL, '/ ') . '/' : $baseURL; - // Based on our baseURL provided by the developer (if set) + // Based on our baseURL provided by the developer // set our current domain name, scheme if (! empty($baseURL)) { - // We cannot add the path here, otherwise it's possible - // that the routing will not work correctly if we are - // within a sub-folder scheme. So it's modified in - // the $this->uri->setScheme(parse_url($baseURL, PHP_URL_SCHEME)); $this->uri->setHost(parse_url($baseURL, PHP_URL_HOST)); $this->uri->setPort(parse_url($baseURL, PHP_URL_PORT)); @@ -715,7 +716,8 @@ } // parse_url() returns false if no host is present, but the path or query string - // contains a colon followed by a number + // contains a colon followed by a number. So we attach a dummy host since + // REQUEST_URI does not include the host. This allows us to parse out the query string and path. $parts = parse_url('http://dummy' . $_SERVER['REQUEST_URI']); $query = $parts['query'] ?? ''; $uri = $parts['path'] ?? ''; diff --git a/system/HTTP/Message.php b/system/HTTP/Message.php index ba7c5a2..1afb1d5 100644 --- a/system/HTTP/Message.php +++ b/system/HTTP/Message.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -84,7 +84,7 @@ /** * Message body * - * @var string + * @var mixed */ protected $body; @@ -108,7 +108,7 @@ /** * Sets the body of the current message. * - * @param $data + * @param mixed $data * * @return Message|Response */ diff --git a/system/HTTP/Negotiate.php b/system/HTTP/Negotiate.php index 4033d7d..6ac2d06 100644 --- a/system/HTTP/Negotiate.php +++ b/system/HTTP/Negotiate.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php index abcf262..8b81077 100644 --- a/system/HTTP/RedirectResponse.php +++ b/system/HTTP/RedirectResponse.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -92,7 +92,7 @@ throw HTTPException::forInvalidRedirectRoute($route); } - return $this->redirect(base_url($route), $method, $code); + return $this->redirect(site_url($route), $method, $code); } /** diff --git a/system/HTTP/Request.php b/system/HTTP/Request.php index ffb90c0..b8b222e 100644 --- a/system/HTTP/Request.php +++ b/system/HTTP/Request.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/RequestInterface.php b/system/HTTP/RequestInterface.php index b88bdbe..fd8f8b3 100644 --- a/system/HTTP/RequestInterface.php +++ b/system/HTTP/RequestInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 80b9366..dca44d2 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -239,13 +239,10 @@ // Also ensures that a Cache-control header exists. $this->noCache(); - // Are we enforcing a Content Security Policy? - if ($config->CSPEnabled === true) - { - $this->CSP = new ContentSecurityPolicy(new \Config\ContentSecurityPolicy()); - $this->CSPEnabled = true; - } + // We need CSP object even if not enabled to avoid calls to non existing methods + $this->CSP = new ContentSecurityPolicy(new \Config\ContentSecurityPolicy()); + $this->CSPEnabled = $config->CSPEnabled; $this->cookiePrefix = $config->cookiePrefix; $this->cookieDomain = $config->cookieDomain; $this->cookiePath = $config->cookiePath; @@ -448,9 +445,9 @@ * * @return $this */ - public function setJSON($body) + public function setJSON($body, bool $unencoded = false) { - $this->body = $this->formatBody($body, 'json'); + $this->body = $this->formatBody($body, 'json' . ($unencoded ? '-unencoded' : '')); return $this; } @@ -538,12 +535,12 @@ */ protected function formatBody($body, string $format) { - $mime = "application/{$format}"; + $this->bodyFormat = ($format === 'json-unencoded' ? 'json' : $format); + $mime = "application/{$this->bodyFormat}"; $this->setContentType($mime); - $this->bodyFormat = $format; // Nothing much to do for a string... - if (! is_string($body)) + if (! is_string($body) || $format === 'json-unencoded') { /** * @var Format $config @@ -713,7 +710,7 @@ // Per spec, MUST be sent with each request, if possible. // http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html - if (! isset($this->headers['Date'])) + if (! isset($this->headers['Date']) && php_sapi_name() !== 'cli-server') { $this->setDate(\DateTime::createFromFormat('U', (string) time())); } @@ -724,7 +721,7 @@ // Send all of our headers foreach ($this->getHeaders() as $name => $values) { - header($name . ': ' . $this->getHeaderLine($name), false, $this->statusCode); + header($name . ': ' . $this->getHeaderLine($name), true, $this->statusCode); } return $this; diff --git a/system/HTTP/ResponseInterface.php b/system/HTTP/ResponseInterface.php index 2ea6c6e..b39339d 100644 --- a/system/HTTP/ResponseInterface.php +++ b/system/HTTP/ResponseInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 33f0081..001b0a9 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -749,27 +749,7 @@ $query = substr($query, 1); } - $temp = explode('&', $query); - $parts = []; - - foreach ($temp as $index => $part) - { - list($key, $value) = $this->splitQueryPart($part); - - // Only 1 part? - if (is_null($value)) - { - $parts[$key] = null; - continue; - } - - // URL Decode the value to protect - // from double-encoding a URL. - // Especially useful with the Pager. - $parts[$this->decode($key)] = $this->decode($value); - } - - $this->query = $parts; + parse_str($query, $this->query); return $this; } @@ -777,53 +757,6 @@ //-------------------------------------------------------------------- /** - * Checks the value to see if it has been urlencoded and decodes it if so. - * The urlencode check is not perfect but should catch most cases. - * - * @param string $value - * - * @return string - */ - protected function decode(string $value): string - { - if (empty($value)) - { - return $value; - } - - $decoded = urldecode($value); - - // This won't catch all cases, specifically - // changing ' ' to '+' has the same length - // but doesn't really matter for our cases here. - return strlen($decoded) < strlen($value) ? $decoded : $value; - } - - /** - * Split a query value into it's key/value elements, if both - * are present. - * - * @param $part - * - * @return array|null - */ - protected function splitQueryPart(string $part) - { - $parts = explode('=', $part, 2); - - // If there's only a single element, no pair, - // then we return null - if (count($parts) === 1) - { - $parts = null; - } - - return $parts; - } - - //-------------------------------------------------------------------- - - /** * A convenience method to pass an array of items in as the Query * portion of the URI. * diff --git a/system/HTTP/UserAgent.php b/system/HTTP/UserAgent.php index 8dc292e..6e5b596 100644 --- a/system/HTTP/UserAgent.php +++ b/system/HTTP/UserAgent.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/array_helper.php b/system/Helpers/array_helper.php index 518c8ae..9c5d8f6 100644 --- a/system/Helpers/array_helper.php +++ b/system/Helpers/array_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/cookie_helper.php b/system/Helpers/cookie_helper.php index a704671..d85f644 100755 --- a/system/Helpers/cookie_helper.php +++ b/system/Helpers/cookie_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/date_helper.php b/system/Helpers/date_helper.php index 5ecf9f7..6cf362a 100644 --- a/system/Helpers/date_helper.php +++ b/system/Helpers/date_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/filesystem_helper.php b/system/Helpers/filesystem_helper.php index 62e7f12..1ead233 100644 --- a/system/Helpers/filesystem_helper.php +++ b/system/Helpers/filesystem_helper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * @package CodeIgniter * @author CodeIgniter Dev Team * @copyright 2008-2014 EllisLab, Inc. (https://ellislab.com/) - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index a260980..82c809c 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index 72891a6..3084771 100755 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -51,11 +51,11 @@ * Generates an HTML unordered list from an single or * multi-dimensional array. * - * @param array $list - * @param string $attributes HTML attributes + * @param array $list + * @param mixed $attributes HTML attributes string, array, object * @return string */ - function ul(array $list, string $attributes = ''): string + function ul(array $list, $attributes = ''): string { return _list('ul', $list, $attributes); } @@ -70,11 +70,11 @@ * * Generates an HTML ordered list from an single or multi-dimensional array. * - * @param array $list - * @param string $attributes HTML attributes + * @param array $list + * @param mixed $attributes HTML attributes string, array, object * @return string */ - function ol(array $list, string $attributes = ''): string + function ol(array $list, $attributes = ''): string { return _list('ol', $list, $attributes); } @@ -91,11 +91,11 @@ * * @param string $type * @param mixed $list - * @param string $attributes + * @param mixed $attributes string, array, object * @param integer $depth * @return string */ - function _list(string $type = 'ul', $list = [], string $attributes = '', int $depth = 0): string + function _list(string $type = 'ul', $list = [], $attributes = '', int $depth = 0): string { // Set the indentation based on the depth $out = str_repeat(' ', $depth) diff --git a/system/Helpers/inflector_helper.php b/system/Helpers/inflector_helper.php index 9389af0..cca140d 100755 --- a/system/Helpers/inflector_helper.php +++ b/system/Helpers/inflector_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/number_helper.php b/system/Helpers/number_helper.php index 2bcc3ed..d1baf76 100644 --- a/system/Helpers/number_helper.php +++ b/system/Helpers/number_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * @package CodeIgniter * @author CodeIgniter Dev Team * @copyright 2008-2014 EllisLab, Inc. (https://ellislab.com/) - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 diff --git a/system/Helpers/security_helper.php b/system/Helpers/security_helper.php index 26ef455..4a324a2 100644 --- a/system/Helpers/security_helper.php +++ b/system/Helpers/security_helper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php index 2bd189c..e4c5e2c 100755 --- a/system/Helpers/text_helper.php +++ b/system/Helpers/text_helper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * @package CodeIgniter * @author CodeIgniter Dev Team * @copyright 2008-2014 EllisLab, Inc. (https://ellislab.com/) - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 9445f18..22813b3 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -111,7 +111,14 @@ // otherwise get rid of the path, because we have // no way of knowing the intent... $config = \CodeIgniter\Config\Services::request()->config; - $url = new \CodeIgniter\HTTP\URI($config->baseURL); + + // If baseUrl does not have a trailing slash it won't resolve + // correctly for users hosting in a subfolder. + $baseUrl = ! empty($config->baseURL) && $config->baseURL !== '/' + ? rtrim($config->baseURL, '/ ') . '/' + : $config->baseURL; + + $url = new \CodeIgniter\HTTP\URI($baseUrl); unset($config); // Merge in the path set by the user, if any @@ -132,7 +139,7 @@ $url->setScheme($protocol); } - return (string) $url; + return rtrim((string) $url, '/ '); } } @@ -152,7 +159,25 @@ */ function current_url(bool $returnObject = false) { - return $returnObject ? \CodeIgniter\Config\Services::request()->uri : (string) \CodeIgniter\Config\Services::request()->uri; + $uri = clone service('request')->uri; + + // If hosted in a sub-folder, we will have additional + // segments that show up prior to the URI path we just + // grabbed from the request, so add it on if necessary. + $baseUri = new \CodeIgniter\HTTP\URI(config('App')->baseURL); + + if (! empty($baseUri->getPath())) + { + $path = rtrim($baseUri->getPath(), '/ ') . '/' . $uri->getPath(); + + $uri->setPath($path); + } + + // Since we're basing off of the IncomingRequest URI, + // we are guaranteed to have a host based on our own configs. + return $returnObject + ? $uri + : (string)$uri->setQuery(''); } } @@ -397,9 +422,9 @@ } else { - for ($i = 0, $l = strlen($attributes); $i < $l; $i ++) + for ($i = 0, $l = mb_strlen($attributes); $i < $l; $i ++) { - $x[] = $attributes[$i]; + $x[] = mb_substr($attributes, $i, 1); } } } diff --git a/system/Helpers/xml_helper.php b/system/Helpers/xml_helper.php index 8209b03..170a896 100644 --- a/system/Helpers/xml_helper.php +++ b/system/Helpers/xml_helper.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 diff --git a/system/Honeypot/Honeypot.php b/system/Honeypot/Honeypot.php index 68d5a62..406e43c 100644 --- a/system/Honeypot/Honeypot.php +++ b/system/Honeypot/Honeypot.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/I18n/Time.php b/system/I18n/Time.php index b26e7fe..a11d7e1 100644 --- a/system/I18n/Time.php +++ b/system/I18n/Time.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/I18n/TimeDifference.php b/system/I18n/TimeDifference.php index 637b448..abfbf76 100644 --- a/system/I18n/TimeDifference.php +++ b/system/I18n/TimeDifference.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index 1c06265..3bd61e8 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/Handlers/GDHandler.php b/system/Images/Handlers/GDHandler.php index 41cb7b4..7f24af5 100644 --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index 97f4a1a..d786166 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/Image.php b/system/Images/Image.php index 1ffe87b..904c78b 100644 --- a/system/Images/Image.php +++ b/system/Images/Image.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Images/ImageHandlerInterface.php b/system/Images/ImageHandlerInterface.php index d0631e8..7727b5f 100644 --- a/system/Images/ImageHandlerInterface.php +++ b/system/Images/ImageHandlerInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/Language.php b/system/Language/Language.php index 1abe60d..65cf58d 100644 --- a/system/Language/Language.php +++ b/system/Language/Language.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -38,7 +38,7 @@ namespace CodeIgniter\Language; -use CodeIgniter\Config\Services; +use Config\Services; /** * Handle system messages and localization. diff --git a/system/Language/en/CLI.php b/system/Language/en/CLI.php index 06eeee3..1afd4f2 100644 --- a/system/Language/en/CLI.php +++ b/system/Language/en/CLI.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Cache.php b/system/Language/en/Cache.php index a89cd87..a6a7038 100644 --- a/system/Language/en/Cache.php +++ b/system/Language/en/Cache.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Cast.php b/system/Language/en/Cast.php index 9d39682..f299df8 100644 --- a/system/Language/en/Cast.php +++ b/system/Language/en/Cast.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Core.php b/system/Language/en/Core.php index a78fc42..d5a49f9 100644 --- a/system/Language/en/Core.php +++ b/system/Language/en/Core.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Database.php b/system/Language/en/Database.php index 08748e3..da88895 100644 --- a/system/Language/en/Database.php +++ b/system/Language/en/Database.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Email.php b/system/Language/en/Email.php index b99117b..6f9fcc4 100644 --- a/system/Language/en/Email.php +++ b/system/Language/en/Email.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/Language/en/Encryption.php b/system/Language/en/Encryption.php index ddf1543..4b4e64c 100644 --- a/system/Language/en/Encryption.php +++ b/system/Language/en/Encryption.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/Language/en/Entity.php b/system/Language/en/Entity.php index 52a014a..1e9fc5e 100644 --- a/system/Language/en/Entity.php +++ b/system/Language/en/Entity.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @filesource diff --git a/system/Language/en/Files.php b/system/Language/en/Files.php index e952144..6ff4878 100644 --- a/system/Language/en/Files.php +++ b/system/Language/en/Files.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Filters.php b/system/Language/en/Filters.php index bc1a882..7a757b2 100644 --- a/system/Language/en/Filters.php +++ b/system/Language/en/Filters.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Format.php b/system/Language/en/Format.php index 0753dd2..c0070c8 100644 --- a/system/Language/en/Format.php +++ b/system/Language/en/Format.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/HTTP.php b/system/Language/en/HTTP.php index 9f94419..2407c0b 100644 --- a/system/Language/en/HTTP.php +++ b/system/Language/en/HTTP.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -38,7 +38,7 @@ 'cannotSetFilepath' => 'When setting binary can not set filepath: {0}', 'notFoundDownloadSource' => 'Not found download body source.', 'cannotSetCache' => 'It does not supported caching for downloading.', - 'cannotSetStatusCode' => 'It does not supported chnage status code for downloading. code: {0}, reason: {1}', + 'cannotSetStatusCode' => 'It does not supported change status code for downloading. code: {0}, reason: {1}', // Response 'missingResponseStatus' => 'HTTP Response is missing a status code', diff --git a/system/Language/en/Images.php b/system/Language/en/Images.php index 740b9e8..9d11da5 100644 --- a/system/Language/en/Images.php +++ b/system/Language/en/Images.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Language.php b/system/Language/en/Language.php index efd395b..5d38ee7 100644 --- a/system/Language/en/Language.php +++ b/system/Language/en/Language.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Log.php b/system/Language/en/Log.php index 8afd8f6..0c8498d 100644 --- a/system/Language/en/Log.php +++ b/system/Language/en/Log.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Migrations.php b/system/Language/en/Migrations.php index efcc94c..efbac6d 100644 --- a/system/Language/en/Migrations.php +++ b/system/Language/en/Migrations.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Number.php b/system/Language/en/Number.php index ec8ea47..149d8a4 100644 --- a/system/Language/en/Number.php +++ b/system/Language/en/Number.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Pager.php b/system/Language/en/Pager.php index 3d4ad91..6e156c4 100644 --- a/system/Language/en/Pager.php +++ b/system/Language/en/Pager.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/RESTful.php b/system/Language/en/RESTful.php index c5d2389..69262a6 100644 --- a/system/Language/en/RESTful.php +++ b/system/Language/en/RESTful.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/Language/en/Redirect.php b/system/Language/en/Redirect.php index 050b97b..da77f14 100644 --- a/system/Language/en/Redirect.php +++ b/system/Language/en/Redirect.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Router.php b/system/Language/en/Router.php index 97b76b5..b305b54 100644 --- a/system/Language/en/Router.php +++ b/system/Language/en/Router.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Session.php b/system/Language/en/Session.php index 5f0dabd..0d12ff0 100644 --- a/system/Language/en/Session.php +++ b/system/Language/en/Session.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Time.php b/system/Language/en/Time.php index ece5f76..92fdf47 100644 --- a/system/Language/en/Time.php +++ b/system/Language/en/Time.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Language/en/Validation.php b/system/Language/en/Validation.php index c9e656f..ac047df 100644 --- a/system/Language/en/Validation.php +++ b/system/Language/en/Validation.php @@ -5,7 +5,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -34,10 +34,12 @@ 'exact_length' => 'The {field} field must be exactly {param} characters in length.', 'greater_than' => 'The {field} field must contain a number greater than {param}.', 'greater_than_equal_to' => 'The {field} field must contain a number greater than or equal to {param}.', + 'hex' => 'The {field} field may only contain hexidecimal characters.', 'in_list' => 'The {field} field must be one of: {param}.', 'integer' => 'The {field} field must contain an integer.', 'is_natural' => 'The {field} field must only contain digits.', 'is_natural_no_zero' => 'The {field} field must only contain digits and must be greater than zero.', + 'is_not_unique' => 'The {field} field must contain a previously existing value in the database.', 'is_unique' => 'The {field} field must contain a unique value.', 'less_than' => 'The {field} field must contain a number less than {param}.', 'less_than_equal_to' => 'The {field} field must contain a number less than or equal to {param}.', diff --git a/system/Language/en/View.php b/system/Language/en/View.php index 0c2a146..eb49e1c 100644 --- a/system/Language/en/View.php +++ b/system/Language/en/View.php @@ -4,7 +4,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Log/Handlers/BaseHandler.php b/system/Log/Handlers/BaseHandler.php index 4b76f89..6874d38 100644 --- a/system/Log/Handlers/BaseHandler.php +++ b/system/Log/Handlers/BaseHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Log/Handlers/ChromeLoggerHandler.php b/system/Log/Handlers/ChromeLoggerHandler.php index 6af3527..bdcd318 100644 --- a/system/Log/Handlers/ChromeLoggerHandler.php +++ b/system/Log/Handlers/ChromeLoggerHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -41,7 +41,7 @@ use CodeIgniter\Events\Events; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Config\Services; +use Config\Services; /** * Class ChromeLoggerHandler diff --git a/system/Log/Handlers/FileHandler.php b/system/Log/Handlers/FileHandler.php index d83750e..78a3218 100644 --- a/system/Log/Handlers/FileHandler.php +++ b/system/Log/Handlers/FileHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -79,7 +79,7 @@ $this->path = $config['path'] ?? WRITEPATH . 'logs/'; - $this->fileExtension = $config['fileExtension'] ?? 'php'; + $this->fileExtension = empty($config['fileExtension']) ? 'log' : $config['fileExtension']; $this->fileExtension = ltrim($this->fileExtension, '.'); $this->filePermissions = $config['filePermissions'] ?? 0644; diff --git a/system/Log/Handlers/HandlerInterface.php b/system/Log/Handlers/HandlerInterface.php index 0e0d01b..6778a46 100644 --- a/system/Log/Handlers/HandlerInterface.php +++ b/system/Log/Handlers/HandlerInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Log/Logger.php b/system/Log/Logger.php index 2219d57..5e95ffd 100644 --- a/system/Log/Logger.php +++ b/system/Log/Logger.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Model.php b/system/Model.php index 8749b2c..38a5488 100644 --- a/system/Model.php +++ b/system/Model.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -242,6 +242,14 @@ protected $skipValidation = false; /** + * Whether rules should be removed that do not exist + * in the passed in data. Used between inserts/updates. + * + * @var boolean + */ + protected $cleanValidationRules = true; + + /** * Our validator instance. * * @var \CodeIgniter\Validation\Validation @@ -381,12 +389,12 @@ $row = $row->getResult($this->tempReturnType); } - $row = $this->trigger('afterFind', ['id' => $id, 'data' => $row]); + $eventData = $this->trigger('afterFind', ['id' => $id, 'data' => $row]); $this->tempReturnType = $this->returnType; $this->tempUseSoftDeletes = $this->useSoftDeletes; - return $row['data']; + return $eventData['data']; } //-------------------------------------------------------------------- @@ -438,12 +446,12 @@ $row = $row->getResult($this->tempReturnType); - $row = $this->trigger('afterFind', ['data' => $row, 'limit' => $limit, 'offset' => $offset]); + $eventData = $this->trigger('afterFind', ['data' => $row, 'limit' => $limit, 'offset' => $offset]); $this->tempReturnType = $this->returnType; $this->tempUseSoftDeletes = $this->useSoftDeletes; - return $row['data']; + return $eventData['data']; } //-------------------------------------------------------------------- @@ -475,11 +483,11 @@ $row = $row->getFirstRow($this->tempReturnType); - $row = $this->trigger('afterFind', ['data' => $row]); + $eventData = $this->trigger('afterFind', ['data' => $row]); $this->tempReturnType = $this->returnType; - return $row['data']; + return $eventData['data']; } //-------------------------------------------------------------------- @@ -682,7 +690,7 @@ // Validate data before saving. if ($this->skipValidation === false) { - if ($this->validate($data) === false) + if ($this->cleanRules(false)->validate($data) === false) { return false; } @@ -705,11 +713,11 @@ $data[$this->updatedField] = $date; } - $data = $this->trigger('beforeInsert', ['data' => $data]); + $eventData = $this->trigger('beforeInsert', ['data' => $data]); // Must use the set() method to ensure objects get converted to arrays $result = $this->builder() - ->set($data['data'], '', $escape) + ->set($eventData['data'], '', $escape) ->insert(); // If insertion succeeded then save the insert ID @@ -719,7 +727,7 @@ } // Trigger afterInsert events with the inserted data and new ID - $this->trigger('afterInsert', ['id' => $this->insertID, 'data' => $data, 'result' => $result]); + $this->trigger('afterInsert', ['id' => $this->insertID, 'data' => $eventData['data'], 'result' => $result]); // If insertion failed, get out of here if (! $result) @@ -750,7 +758,7 @@ { foreach ($set as $row) { - if ($this->validate($row) === false) + if ($this->cleanRules(false)->validate($row) === false) { return false; } @@ -812,7 +820,7 @@ // Validate data before saving. if ($this->skipValidation === false) { - if ($this->validate($data) === false) + if ($this->cleanRules(true)->validate($data) === false) { return false; } @@ -827,7 +835,7 @@ $data[$this->updatedField] = $this->setDate(); } - $data = $this->trigger('beforeUpdate', ['id' => $id, 'data' => $data]); + $eventData = $this->trigger('beforeUpdate', ['id' => $id, 'data' => $data]); $builder = $this->builder(); @@ -838,10 +846,10 @@ // Must use the set() method to ensure objects get converted to arrays $result = $builder - ->set($data['data'], '', $escape) + ->set($eventData['data'], '', $escape) ->update(); - $this->trigger('afterUpdate', ['id' => $id, 'data' => $data, 'result' => $result]); + $this->trigger('afterUpdate', ['id' => $id, 'data' => $eventData['data'], 'result' => $result]); return $result; } @@ -867,7 +875,7 @@ { foreach ($set as $row) { - if ($this->validate($row) === false) + if ($this->cleanRules(true)->validate($row) === false) { return false; } @@ -1005,7 +1013,7 @@ // Validate data before saving. if (! empty($data) && $this->skipValidation === false) { - if ($this->validate($data) === false) + if ($this->cleanRules(true)->validate($data) === false) { return false; } @@ -1114,14 +1122,13 @@ */ public function paginate(int $perPage = 20, string $group = 'default', int $page = 0) { - // Get the necessary parts. - $page = $page >= 1 ? $page : (ctype_digit($_GET['page'] ?? '') && $_GET['page'] > 1 ? $_GET['page'] : 1); + $pager = \Config\Services::pager(null, null, false); + $page = $page >= 1 ? $page : $pager->getCurrentPage($group); $total = $this->countAllResults(false); // Store it in the Pager library so it can be // paginated in the views. - $pager = \Config\Services::pager(); $this->pager = $pager->store($group, $page, $perPage, $total); $offset = ($page - 1) * $perPage; @@ -1360,6 +1367,23 @@ //-------------------------------------------------------------------- /** + * Should validation rules be removed before saving? + * Most handy when doing updates. + * + * @param boolean $choice + * + * @return $this + */ + public function cleanRules(bool $choice = false) + { + $this->cleanValidationRules = $choice; + + return $this; + } + + //-------------------------------------------------------------------- + + /** * Validate the data against the validation rules (or the validation group) * specified in the class property, $validationRules. * @@ -1390,7 +1414,9 @@ $rules = $this->validation->loadRuleGroup($rules); } - $rules = $this->cleanValidationRules($rules, $data); + $rules = $this->cleanValidationRules + ? $this->cleanValidationRules($rules, $data) + : $rules; // If no data existed that needs validation // our job is done here. @@ -1564,22 +1590,22 @@ * It is the responsibility of the callback methods to return * the data itself. * - * Each $data array MUST have a 'data' key with the relevant + * Each $eventData array MUST have a 'data' key with the relevant * data for callback methods (like an array of key/value pairs to insert * or update, an array of results, etc) * * @param string $event - * @param array $data + * @param array $eventData * * @return mixed * @throws \CodeIgniter\Database\Exceptions\DataException */ - protected function trigger(string $event, array $data) + protected function trigger(string $event, array $eventData) { // Ensure it's a valid event if (! isset($this->{$event}) || empty($this->{$event})) { - return $data; + return $eventData; } foreach ($this->{$event} as $callback) @@ -1589,10 +1615,10 @@ throw DataException::forInvalidMethodTriggered($callback); } - $data = $this->{$callback}($data); + $eventData = $this->{$callback}($eventData); } - return $data; + return $eventData; } //-------------------------------------------------------------------- diff --git a/system/Pager/Pager.php b/system/Pager/Pager.php index b80b0e8..8aecd5f 100644 --- a/system/Pager/Pager.php +++ b/system/Pager/Pager.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -348,7 +348,7 @@ } else { - $uri->addQuery('page', $page); + $uri->addQuery($this->groups[$group]['pageSelector'], $page); } if ($this->only) @@ -357,7 +357,7 @@ if (! $segment) { - $query['page'] = $page; + $query[$this->groups[$group]['pageSelector']] = $page; } $uri->setQueryArray($query); @@ -503,13 +503,31 @@ } $this->groups[$group] = [ - 'uri' => clone Services::request()->uri, - 'hasMore' => false, - 'total' => null, - 'perPage' => $this->config->perPage, - 'pageCount' => 1, + 'uri' => clone current_url(true), + 'hasMore' => false, + 'total' => null, + 'perPage' => $this->config->perPage, + 'pageCount' => 1, + 'pageSelector' => $group === 'default' ? 'page' : 'page_' . $group, ]; + $this->calculateCurrentPage($group); + + if ($_GET) + { + $this->groups[$group]['uri'] = $this->groups[$group]['uri']->setQueryArray($_GET); + } + } + + //-------------------------------------------------------------------- + + /** + * Calculating the current page + * + * @param string $group + */ + protected function calculateCurrentPage(string $group) + { if (array_key_exists($group, $this->segment)) { try @@ -523,12 +541,11 @@ } else { - $this->groups[$group]['currentPage'] = $_GET['page_' . $group] ?? $_GET['page'] ?? 1; - } + $pageSelector = $this->groups[$group]['pageSelector']; - if ($_GET) - { - $this->groups[$group]['uri'] = $this->groups[$group]['uri']->setQueryArray($_GET); + $page = (int) ($_GET[$pageSelector] ?? 1); + + $this->groups[$group]['currentPage'] = $page < 1 ? 1 : $page; } } diff --git a/system/Pager/PagerInterface.php b/system/Pager/PagerInterface.php index 5a56bc4..9f975b5 100644 --- a/system/Pager/PagerInterface.php +++ b/system/Pager/PagerInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Pager/PagerRenderer.php b/system/Pager/PagerRenderer.php index c21ba40..1712ddf 100644 --- a/system/Pager/PagerRenderer.php +++ b/system/Pager/PagerRenderer.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -93,6 +93,12 @@ * @var integer */ protected $segment; + /** + * Name of $_GET parameter + * + * @var integer + */ + protected $pageSelector; //-------------------------------------------------------------------- @@ -103,13 +109,14 @@ */ public function __construct(array $details) { - $this->first = 1; - $this->last = $details['pageCount']; - $this->current = $details['currentPage']; - $this->total = $details['total']; - $this->uri = $details['uri']; - $this->pageCount = $details['pageCount']; - $this->segment = $details['segment'] ?? 0; + $this->first = 1; + $this->last = $details['pageCount']; + $this->current = $details['currentPage']; + $this->total = $details['total']; + $this->uri = $details['uri']; + $this->pageCount = $details['pageCount']; + $this->segment = $details['segment'] ?? 0; + $this->pageSelector = $details['pageSelector'] ?? 'page'; } //-------------------------------------------------------------------- @@ -164,7 +171,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', $this->first - 1); + $uri->addQuery($this->pageSelector, $this->first - 1); } else { @@ -208,7 +215,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', $this->last + 1); + $uri->addQuery($this->pageSelector, $this->last + 1); } else { @@ -231,7 +238,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', 1); + $uri->addQuery($this->pageSelector, 1); } else { @@ -254,7 +261,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', $this->pageCount); + $uri->addQuery($this->pageSelector, $this->pageCount); } else { @@ -277,7 +284,7 @@ if ($this->segment === 0) { - $uri->addQuery('page', $this->current); + $uri->addQuery($this->pageSelector, $this->current); } else { @@ -306,7 +313,7 @@ for ($i = $this->first; $i <= $this->last; $i ++) { $links[] = [ - 'uri' => (string) ($this->segment === 0 ? $uri->addQuery('page', $i) : $uri->setSegment($this->segment, $i)), + 'uri' => (string) ($this->segment === 0 ? $uri->addQuery($this->pageSelector, $i) : $uri->setSegment($this->segment, $i)), 'title' => (int) $i, 'active' => ($i === $this->current), ]; diff --git a/system/RESTful/ResourceController.php b/system/RESTful/ResourceController.php index 3ca495d..4aaec7c 100644 --- a/system/RESTful/ResourceController.php +++ b/system/RESTful/ResourceController.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/RESTful/ResourcePresenter.php b/system/RESTful/ResourcePresenter.php index 3ac0676..2d970e3 100644 --- a/system/RESTful/ResourcePresenter.php +++ b/system/RESTful/ResourcePresenter.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 3.0.0 diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 6cc01b4..53a27e7 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -653,6 +653,10 @@ { $to = $this->routes['*'][$to]['route']; } + else if (array_key_exists($to, $this->routes['get'])) + { + $to = $this->routes['get'][$to]['route']; + } $this->create('*', $from, $to, ['redirect' => $status]); @@ -1382,7 +1386,7 @@ } // Limiting to subdomains? - else if (isset($options['subdomain']) && ! empty($options['subdomain'])) + else if (! empty($options['subdomain'])) { // If we don't match the current subdomain, then // we don't need to add the route. @@ -1420,7 +1424,7 @@ } // If no namespace found, add the default namespace - if (is_string($to) && strpos($to, '\\') === false) + if (is_string($to) && (strpos($to, '\\') === false || strpos($to, '\\') > 0)) { $namespace = $options['namespace'] ?? $this->defaultNamespace; $to = trim($namespace, '\\') . '\\' . $to; diff --git a/system/Router/RouteCollectionInterface.php b/system/Router/RouteCollectionInterface.php index a6ae721..b25e93d 100644 --- a/system/Router/RouteCollectionInterface.php +++ b/system/Router/RouteCollectionInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Router/Router.php b/system/Router/Router.php index 185e94f..14f24c6 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -424,6 +424,11 @@ // Does the RegEx match? if (preg_match('#^' . $key . '$#', $uri, $matches)) { + // Is this route supposed to redirect to another? + if ($this->collection->isRedirect($key)) + { + throw new RedirectException(key($val), $this->collection->getRedirectCode($key)); + } // Store our locale so CodeIgniter object can // assign it to the Request. if (isset($localeSegment)) @@ -482,12 +487,6 @@ $val = $controller . '::' . $method; } - // Is this route supposed to redirect to another? - if ($this->collection->isRedirect($key)) - { - throw new RedirectException($val, $this->collection->getRedirectCode($key)); - } - $this->setRequest(explode('/', $val)); $this->matchedRoute = [ diff --git a/system/Router/RouterInterface.php b/system/Router/RouterInterface.php index 7adb860..46cb285 100644 --- a/system/Router/RouterInterface.php +++ b/system/Router/RouterInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Security/Security.php b/system/Security/Security.php index cef7815..28318d9 100644 --- a/system/Security/Security.php +++ b/system/Security/Security.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/ArrayHandler.php b/system/Session/Handlers/ArrayHandler.php index 9f71ada..90eb920 100644 --- a/system/Session/Handlers/ArrayHandler.php +++ b/system/Session/Handlers/ArrayHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/BaseHandler.php b/system/Session/Handlers/BaseHandler.php index d9fa7fa..4d8264d 100644 --- a/system/Session/Handlers/BaseHandler.php +++ b/system/Session/Handlers/BaseHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/DatabaseHandler.php b/system/Session/Handlers/DatabaseHandler.php index 77ed74f..3290a3a 100644 --- a/system/Session/Handlers/DatabaseHandler.php +++ b/system/Session/Handlers/DatabaseHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/FileHandler.php b/system/Session/Handlers/FileHandler.php index f046b9d..19fc57f 100644 --- a/system/Session/Handlers/FileHandler.php +++ b/system/Session/Handlers/FileHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/MemcachedHandler.php b/system/Session/Handlers/MemcachedHandler.php index 0fa2486..f35405e 100644 --- a/system/Session/Handlers/MemcachedHandler.php +++ b/system/Session/Handlers/MemcachedHandler.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Handlers/RedisHandler.php b/system/Session/Handlers/RedisHandler.php index 900cd4b..513e0d2 100644 --- a/system/Session/Handlers/RedisHandler.php +++ b/system/Session/Handlers/RedisHandler.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Session/Session.php b/system/Session/Session.php index d0960db..ff40a47 100644 --- a/system/Session/Session.php +++ b/system/Session/Session.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -497,7 +497,7 @@ */ public function get(string $key = null) { - if (! empty($key) && ! is_null($value = dot_array_search($key, $_SESSION))) + if (! empty($key) && ! is_null($value = dot_array_search($key, $_SESSION ?? []))) { return $value; } diff --git a/system/Session/SessionInterface.php b/system/Session/SessionInterface.php index 820419a..e098514 100644 --- a/system/Session/SessionInterface.php +++ b/system/Session/SessionInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/CIDatabaseTestCase.php b/system/Test/CIDatabaseTestCase.php index 9e177fc..926e1a9 100644 --- a/system/Test/CIDatabaseTestCase.php +++ b/system/Test/CIDatabaseTestCase.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/CIUnitTestCase.php b/system/Test/CIUnitTestCase.php index 4d2dc80..54208bf 100644 --- a/system/Test/CIUnitTestCase.php +++ b/system/Test/CIUnitTestCase.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/ControllerResponse.php b/system/Test/ControllerResponse.php index 1215842..a187ce7 100644 --- a/system/Test/ControllerResponse.php +++ b/system/Test/ControllerResponse.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/ControllerTester.php b/system/Test/ControllerTester.php index ed8fac6..d6dc0b6 100644 --- a/system/Test/ControllerTester.php +++ b/system/Test/ControllerTester.php @@ -9,7 +9,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -129,6 +129,11 @@ $this->appConfig = new App(); } + if (! $this->uri instanceof URI) + { + $this->uri = new URI($this->appConfig->baseURL ?? 'http://example.com'); + } + if (empty($this->request)) { $this->request = new IncomingRequest($this->appConfig, $this->uri, $this->body, new UserAgent()); diff --git a/system/Test/DOMParser.php b/system/Test/DOMParser.php index d0d6af8..1872a68 100644 --- a/system/Test/DOMParser.php +++ b/system/Test/DOMParser.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/FeatureResponse.php b/system/Test/FeatureResponse.php index 362161f..9f2b193 100644 --- a/system/Test/FeatureResponse.php +++ b/system/Test/FeatureResponse.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/FeatureTestCase.php b/system/Test/FeatureTestCase.php index 356b38a..6308988 100644 --- a/system/Test/FeatureTestCase.php +++ b/system/Test/FeatureTestCase.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/Filters/CITestStreamFilter.php b/system/Test/Filters/CITestStreamFilter.php index 449f688..4310a7f 100644 --- a/system/Test/Filters/CITestStreamFilter.php +++ b/system/Test/Filters/CITestStreamFilter.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Test/ReflectionHelper.php b/system/Test/ReflectionHelper.php index 2719b44..5bdfa98 100644 --- a/system/Test/ReflectionHelper.php +++ b/system/Test/ReflectionHelper.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/ThirdParty/Escaper/Escaper.php b/system/ThirdParty/Escaper/Escaper.php new file mode 100644 index 0000000..9f903a5 --- /dev/null +++ b/system/ThirdParty/Escaper/Escaper.php @@ -0,0 +1,391 @@ + 'quot', // quotation mark + 38 => 'amp', // ampersand + 60 => 'lt', // less-than sign + 62 => 'gt', // greater-than sign + ]; + + /** + * Current encoding for escaping. If not UTF-8, we convert strings from this encoding + * pre-escaping and back to this encoding post-escaping. + * + * @var string + */ + protected $encoding = 'utf-8'; + + /** + * Holds the value of the special flags passed as second parameter to + * htmlspecialchars(). + * + * @var int + */ + protected $htmlSpecialCharsFlags; + + /** + * Static Matcher which escapes characters for HTML Attribute contexts + * + * @var callable + */ + protected $htmlAttrMatcher; + + /** + * Static Matcher which escapes characters for Javascript contexts + * + * @var callable + */ + protected $jsMatcher; + + /** + * Static Matcher which escapes characters for CSS Attribute contexts + * + * @var callable + */ + protected $cssMatcher; + + /** + * List of all encoding supported by this class + * + * @var array + */ + protected $supportedEncodings = [ + 'iso-8859-1', 'iso8859-1', 'iso-8859-5', 'iso8859-5', + 'iso-8859-15', 'iso8859-15', 'utf-8', 'cp866', + 'ibm866', '866', 'cp1251', 'windows-1251', + 'win-1251', '1251', 'cp1252', 'windows-1252', + '1252', 'koi8-r', 'koi8-ru', 'koi8r', + 'big5', '950', 'gb2312', '936', + 'big5-hkscs', 'shift_jis', 'sjis', 'sjis-win', + 'cp932', '932', 'euc-jp', 'eucjp', + 'eucjp-win', 'macroman' + ]; + + /** + * Constructor: Single parameter allows setting of global encoding for use by + * the current object. + * + * @param string $encoding + * @throws Exception\InvalidArgumentException + */ + public function __construct($encoding = null) + { + if ($encoding !== null) { + if (! is_string($encoding)) { + throw new Exception\InvalidArgumentException( + get_class($this) . ' constructor parameter must be a string, received ' . gettype($encoding) + ); + } + if ($encoding === '') { + throw new Exception\InvalidArgumentException( + get_class($this) . ' constructor parameter does not allow a blank value' + ); + } + + $encoding = strtolower($encoding); + if (! in_array($encoding, $this->supportedEncodings)) { + throw new Exception\InvalidArgumentException( + 'Value of \'' . $encoding . '\' passed to ' . get_class($this) + . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' + ); + } + + $this->encoding = $encoding; + } + + // We take advantage of ENT_SUBSTITUTE flag to correctly deal with invalid UTF-8 sequences. + $this->htmlSpecialCharsFlags = ENT_QUOTES | ENT_SUBSTITUTE; + + // set matcher callbacks + $this->htmlAttrMatcher = [$this, 'htmlAttrMatcher']; + $this->jsMatcher = [$this, 'jsMatcher']; + $this->cssMatcher = [$this, 'cssMatcher']; + } + + /** + * Return the encoding that all output/input is expected to be encoded in. + * + * @return string + */ + public function getEncoding() + { + return $this->encoding; + } + + /** + * Escape a string for the HTML Body context where there are very few characters + * of special meaning. Internally this will use htmlspecialchars(). + * + * @param string $string + * @return string + */ + public function escapeHtml($string) + { + return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); + } + + /** + * Escape a string for the HTML Attribute context. We use an extended set of characters + * to escape that are not covered by htmlspecialchars() to cover cases where an attribute + * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE). + * + * @param string $string + * @return string + */ + public function escapeHtmlAttr($string) + { + $string = $this->toUtf8($string); + if ($string === '' || ctype_digit($string)) { + return $string; + } + + $result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string); + return $this->fromUtf8($result); + } + + /** + * Escape a string for the Javascript context. This does not use json_encode(). An extended + * set of characters are escaped beyond ECMAScript's rules for Javascript literal string + * escaping in order to prevent misinterpretation of Javascript as HTML leading to the + * injection of special characters and entities. The escaping used should be tolerant + * of cases where HTML escaping was not applied on top of Javascript escaping correctly. + * Backslash escaping is not used as it still leaves the escaped character as-is and so + * is not useful in a HTML context. + * + * @param string $string + * @return string + */ + public function escapeJs($string) + { + $string = $this->toUtf8($string); + if ($string === '' || ctype_digit($string)) { + return $string; + } + + $result = preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string); + return $this->fromUtf8($result); + } + + /** + * Escape a string for the URI or Parameter contexts. This should not be used to escape + * an entire URI - only a subcomponent being inserted. The function is a simple proxy + * to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely. + * + * @param string $string + * @return string + */ + public function escapeUrl($string) + { + return rawurlencode($string); + } + + /** + * Escape a string for the CSS context. CSS escaping can be applied to any string being + * inserted into CSS and escapes everything except alphanumerics. + * + * @param string $string + * @return string + */ + public function escapeCss($string) + { + $string = $this->toUtf8($string); + if ($string === '' || ctype_digit($string)) { + return $string; + } + + $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string); + return $this->fromUtf8($result); + } + + /** + * Callback function for preg_replace_callback that applies HTML Attribute + * escaping to all matches. + * + * @param array $matches + * @return string + */ + protected function htmlAttrMatcher($matches) + { + $chr = $matches[0]; + $ord = ord($chr); + + /** + * The following replaces characters undefined in HTML with the + * hex entity for the Unicode replacement character. + */ + if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") + || ($ord >= 0x7f && $ord <= 0x9f) + ) { + return '�'; + } + + /** + * Check if the current character to escape has a name entity we should + * replace it with while grabbing the integer value of the character. + */ + if (strlen($chr) > 1) { + $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); + } + + $hex = bin2hex($chr); + $ord = hexdec($hex); + if (isset(static::$htmlNamedEntityMap[$ord])) { + return '&' . static::$htmlNamedEntityMap[$ord] . ';'; + } + + /** + * Per OWASP recommendations, we'll use upper hex entities + * for any other characters where a named entity does not exist. + */ + if ($ord > 255) { + return sprintf('%04X;', $ord); + } + return sprintf('%02X;', $ord); + } + + /** + * Callback function for preg_replace_callback that applies Javascript + * escaping to all matches. + * + * @param array $matches + * @return string + */ + protected function jsMatcher($matches) + { + $chr = $matches[0]; + if (strlen($chr) == 1) { + return sprintf('\\x%02X', ord($chr)); + } + $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); + $hex = strtoupper(bin2hex($chr)); + if (strlen($hex) <= 4) { + return sprintf('\\u%04s', $hex); + } + $highSurrogate = substr($hex, 0, 4); + $lowSurrogate = substr($hex, 4, 4); + return sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate); + } + + /** + * Callback function for preg_replace_callback that applies CSS + * escaping to all matches. + * + * @param array $matches + * @return string + */ + protected function cssMatcher($matches) + { + $chr = $matches[0]; + if (strlen($chr) == 1) { + $ord = ord($chr); + } else { + $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); + $ord = hexdec(bin2hex($chr)); + } + return sprintf('\\%X ', $ord); + } + + /** + * Converts a string to UTF-8 from the base encoding. The base encoding is set via this + * class' constructor. + * + * @param string $string + * @throws Exception\RuntimeException + * @return string + */ + protected function toUtf8($string) + { + if ($this->getEncoding() === 'utf-8') { + $result = $string; + } else { + $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); + } + + if (! $this->isUtf8($result)) { + throw new Exception\RuntimeException( + sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) + ); + } + + return $result; + } + + /** + * Converts a string from UTF-8 to the base encoding. The base encoding is set via this + * class' constructor. + * @param string $string + * @return string + */ + protected function fromUtf8($string) + { + if ($this->getEncoding() === 'utf-8') { + return $string; + } + + return $this->convertEncoding($string, $this->getEncoding(), 'UTF-8'); + } + + /** + * Checks if a given string appears to be valid UTF-8 or not. + * + * @param string $string + * @return bool + */ + protected function isUtf8($string) + { + return ($string === '' || preg_match('/^./su', $string)); + } + + /** + * Encoding conversion helper which wraps iconv and mbstring where they exist or throws + * and exception where neither is available. + * + * @param string $string + * @param string $to + * @param array|string $from + * @throws Exception\RuntimeException + * @return string + */ + protected function convertEncoding($string, $to, $from) + { + if (function_exists('iconv')) { + $result = iconv($from, $to, $string); + } elseif (function_exists('mb_convert_encoding')) { + $result = mb_convert_encoding($string, $to, $from); + } else { + throw new Exception\RuntimeException( + get_class($this) + . ' requires either the iconv or mbstring extension to be installed' + . ' when escaping for non UTF-8 strings.' + ); + } + + if ($result === false) { + return ''; // return non-fatal blank string on encoding errors from users + } + return $result; + } +} diff --git a/system/ThirdParty/Escaper/Exception/ExceptionInterface.php b/system/ThirdParty/Escaper/Exception/ExceptionInterface.php new file mode 100644 index 0000000..7ebe04e --- /dev/null +++ b/system/ThirdParty/Escaper/Exception/ExceptionInterface.php @@ -0,0 +1,13 @@ + 'quot', // quotation mark - 38 => 'amp', // ampersand - 60 => 'lt', // less-than sign - 62 => 'gt', // greater-than sign - ]; - - /** - * Current encoding for escaping. If not UTF-8, we convert strings from this encoding - * pre-escaping and back to this encoding post-escaping. - * - * @var string - */ - protected $encoding = 'utf-8'; - - /** - * Holds the value of the special flags passed as second parameter to - * htmlspecialchars(). - * - * @var int - */ - protected $htmlSpecialCharsFlags; - - /** - * Static Matcher which escapes characters for HTML Attribute contexts - * - * @var callable - */ - protected $htmlAttrMatcher; - - /** - * Static Matcher which escapes characters for Javascript contexts - * - * @var callable - */ - protected $jsMatcher; - - /** - * Static Matcher which escapes characters for CSS Attribute contexts - * - * @var callable - */ - protected $cssMatcher; - - /** - * List of all encoding supported by this class - * - * @var array - */ - protected $supportedEncodings = [ - 'iso-8859-1', 'iso8859-1', 'iso-8859-5', 'iso8859-5', - 'iso-8859-15', 'iso8859-15', 'utf-8', 'cp866', - 'ibm866', '866', 'cp1251', 'windows-1251', - 'win-1251', '1251', 'cp1252', 'windows-1252', - '1252', 'koi8-r', 'koi8-ru', 'koi8r', - 'big5', '950', 'gb2312', '936', - 'big5-hkscs', 'shift_jis', 'sjis', 'sjis-win', - 'cp932', '932', 'euc-jp', 'eucjp', - 'eucjp-win', 'macroman' - ]; - - /** - * Constructor: Single parameter allows setting of global encoding for use by - * the current object. - * - * @param string $encoding - * @throws Exception\InvalidArgumentException - */ - public function __construct($encoding = null) - { - if ($encoding !== null) { - if (! is_string($encoding)) { - throw new Exception\InvalidArgumentException( - get_class($this) . ' constructor parameter must be a string, received ' . gettype($encoding) - ); - } - if ($encoding === '') { - throw new Exception\InvalidArgumentException( - get_class($this) . ' constructor parameter does not allow a blank value' - ); - } - - $encoding = strtolower($encoding); - if (! in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException( - 'Value of \'' . $encoding . '\' passed to ' . get_class($this) - . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' - ); - } - - $this->encoding = $encoding; - } - - // We take advantage of ENT_SUBSTITUTE flag to correctly deal with invalid UTF-8 sequences. - $this->htmlSpecialCharsFlags = ENT_QUOTES | ENT_SUBSTITUTE; - - // set matcher callbacks - $this->htmlAttrMatcher = [$this, 'htmlAttrMatcher']; - $this->jsMatcher = [$this, 'jsMatcher']; - $this->cssMatcher = [$this, 'cssMatcher']; - } - - /** - * Return the encoding that all output/input is expected to be encoded in. - * - * @return string - */ - public function getEncoding() - { - return $this->encoding; - } - - /** - * Escape a string for the HTML Body context where there are very few characters - * of special meaning. Internally this will use htmlspecialchars(). - * - * @param string $string - * @return string - */ - public function escapeHtml($string) - { - return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); - } - - /** - * Escape a string for the HTML Attribute context. We use an extended set of characters - * to escape that are not covered by htmlspecialchars() to cover cases where an attribute - * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE). - * - * @param string $string - * @return string - */ - public function escapeHtmlAttr($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Escape a string for the Javascript context. This does not use json_encode(). An extended - * set of characters are escaped beyond ECMAScript's rules for Javascript literal string - * escaping in order to prevent misinterpretation of Javascript as HTML leading to the - * injection of special characters and entities. The escaping used should be tolerant - * of cases where HTML escaping was not applied on top of Javascript escaping correctly. - * Backslash escaping is not used as it still leaves the escaped character as-is and so - * is not useful in a HTML context. - * - * @param string $string - * @return string - */ - public function escapeJs($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Escape a string for the URI or Parameter contexts. This should not be used to escape - * an entire URI - only a subcomponent being inserted. The function is a simple proxy - * to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely. - * - * @param string $string - * @return string - */ - public function escapeUrl($string) - { - return rawurlencode($string); - } - - /** - * Escape a string for the CSS context. CSS escaping can be applied to any string being - * inserted into CSS and escapes everything except alphanumerics. - * - * @param string $string - * @return string - */ - public function escapeCss($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Callback function for preg_replace_callback that applies HTML Attribute - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function htmlAttrMatcher($matches) - { - $chr = $matches[0]; - $ord = ord($chr); - - /** - * The following replaces characters undefined in HTML with the - * hex entity for the Unicode replacement character. - */ - if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") - || ($ord >= 0x7f && $ord <= 0x9f) - ) { - return '�'; - } - - /** - * Check if the current character to escape has a name entity we should - * replace it with while grabbing the integer value of the character. - */ - if (strlen($chr) > 1) { - $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); - } - - $hex = bin2hex($chr); - $ord = hexdec($hex); - if (isset(static::$htmlNamedEntityMap[$ord])) { - return '&' . static::$htmlNamedEntityMap[$ord] . ';'; - } - - /** - * Per OWASP recommendations, we'll use upper hex entities - * for any other characters where a named entity does not exist. - */ - if ($ord > 255) { - return sprintf('%04X;', $ord); - } - return sprintf('%02X;', $ord); - } - - /** - * Callback function for preg_replace_callback that applies Javascript - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function jsMatcher($matches) - { - $chr = $matches[0]; - if (strlen($chr) == 1) { - return sprintf('\\x%02X', ord($chr)); - } - $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); - $hex = strtoupper(bin2hex($chr)); - if (strlen($hex) <= 4) { - return sprintf('\\u%04s', $hex); - } - $highSurrogate = substr($hex, 0, 4); - $lowSurrogate = substr($hex, 4, 4); - return sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate); - } - - /** - * Callback function for preg_replace_callback that applies CSS - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function cssMatcher($matches) - { - $chr = $matches[0]; - if (strlen($chr) == 1) { - $ord = ord($chr); - } else { - $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); - $ord = hexdec(bin2hex($chr)); - } - return sprintf('\\%X ', $ord); - } - - /** - * Converts a string to UTF-8 from the base encoding. The base encoding is set via this - * class' constructor. - * - * @param string $string - * @throws Exception\RuntimeException - * @return string - */ - protected function toUtf8($string) - { - if ($this->getEncoding() === 'utf-8') { - $result = $string; - } else { - $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); - } - - if (! $this->isUtf8($result)) { - throw new Exception\RuntimeException( - sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) - ); - } - - return $result; - } - - /** - * Converts a string from UTF-8 to the base encoding. The base encoding is set via this - * class' constructor. - * @param string $string - * @return string - */ - protected function fromUtf8($string) - { - if ($this->getEncoding() === 'utf-8') { - return $string; - } - - return $this->convertEncoding($string, $this->getEncoding(), 'UTF-8'); - } - - /** - * Checks if a given string appears to be valid UTF-8 or not. - * - * @param string $string - * @return bool - */ - protected function isUtf8($string) - { - return ($string === '' || preg_match('/^./su', $string)); - } - - /** - * Encoding conversion helper which wraps iconv and mbstring where they exist or throws - * and exception where neither is available. - * - * @param string $string - * @param string $to - * @param array|string $from - * @throws Exception\RuntimeException - * @return string - */ - protected function convertEncoding($string, $to, $from) - { - if (function_exists('iconv')) { - $result = iconv($from, $to, $string); - } elseif (function_exists('mb_convert_encoding')) { - $result = mb_convert_encoding($string, $to, $from); - } else { - throw new Exception\RuntimeException( - get_class($this) - . ' requires either the iconv or mbstring extension to be installed' - . ' when escaping for non UTF-8 strings.' - ); - } - - if ($result === false) { - return ''; // return non-fatal blank string on encoding errors from users - } - return $result; - } -} diff --git a/system/ThirdParty/ZendEscaper/Exception/ExceptionInterface.php b/system/ThirdParty/ZendEscaper/Exception/ExceptionInterface.php deleted file mode 100644 index 7174796..0000000 --- a/system/ThirdParty/ZendEscaper/Exception/ExceptionInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if ($file->getSize() / 1024 > $params[0]) { return false; @@ -173,6 +178,11 @@ return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + // We know that our mimes list always has the first mime // start with `image` even when then are multiple accepted types. $type = \Config\Mimes::guessTypeFromExtension($file->getExtension()); @@ -216,6 +226,11 @@ return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if (! in_array($file->getMimeType(), $params)) { return false; @@ -255,6 +270,11 @@ return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if (! in_array($file->getExtension(), $params)) { return false; @@ -295,6 +315,11 @@ return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + // Get Parameter sizes $allowedWidth = $params[0] ?? 0; $allowedHeight = $params[1] ?? 0; diff --git a/system/Validation/FormatRules.php b/system/Validation/FormatRules.php index 11d5ade..c8572b0 100644 --- a/system/Validation/FormatRules.php +++ b/system/Validation/FormatRules.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -154,6 +154,20 @@ //-------------------------------------------------------------------- /** + * String of hexidecimal characters + * + * @param string $str + * + * @return boolean + */ + public function hex(string $str = null): bool + { + return ctype_xdigit($str); + } + + //-------------------------------------------------------------------- + + /** * Integer * * @param string $str diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index c27e045..fb09e7b 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -140,6 +140,47 @@ //-------------------------------------------------------------------- /** + * Checks the database to see if the given value exist. + * Can ignore records by field/value to filter (currently + * accept only one filter). + * + * Example: + * is_not_unique[table.field,where_field,where_value] + * is_not_unique[menu.id,active,1] + * + * @param string $str + * @param string $field + * @param array $data + * + * @return boolean + */ + public function is_not_unique(string $str = null, string $field, array $data): bool + { + // Grab any data for exclusion of a single row. + list($field, $where_field, $where_value) = array_pad(explode(',', $field), 3, null); + + // Break the table and field apart + sscanf($field, '%[^.].%[^.]', $table, $field); + + $db = Database::connect($data['DBGroup'] ?? null); + + $row = $db->table($table) + ->select('1') + ->where($field, $str) + ->limit(1); + + if (! empty($where_field) && ! empty($where_value)) + { + $row = $row->where($where_field, $where_value); + } + + return (bool) ($row->get() + ->getRow() !== null); + } + + //-------------------------------------------------------------------- + + /** * Value should be within an array of values * * @param string $value diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index c55e27c..959194c 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/Validation/ValidationInterface.php b/system/Validation/ValidationInterface.php index ba4981f..cda21e0 100644 --- a/system/Validation/ValidationInterface.php +++ b/system/Validation/ValidationInterface.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/View/Cell.php b/system/View/Cell.php index ff92f02..a7e79e9 100644 --- a/system/View/Cell.php +++ b/system/View/Cell.php @@ -7,7 +7,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -41,6 +41,7 @@ use CodeIgniter\Cache\CacheInterface; use CodeIgniter\View\Exceptions\ViewException; use ReflectionMethod; +use Config\Services; /** * Class Cell @@ -119,6 +120,11 @@ // Not cached - so grab it... $instance = new $class(); + if (method_exists($instance, 'initController')) + { + $instance->initController(Services::request(), Services::response(), Services::logger()); + } + if (! method_exists($instance, $method)) { throw ViewException::forInvalidCellMethod($class, $method); diff --git a/system/View/Filters.php b/system/View/Filters.php index f17c324..ad18ec8 100644 --- a/system/View/Filters.php +++ b/system/View/Filters.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/system/View/Parser.php b/system/View/Parser.php index d24dad5..1e7bc30 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 @@ -414,7 +414,10 @@ $str .= $out; } - $replace['#' . $match[0] . '#s'] = $str; + //Escape | character from filters as it's handled as OR in regex + $escaped_match = preg_replace('/(?sections[$sectionName] as $contents) + foreach ($this->sections[$sectionName] as $key => $contents) { echo $contents; + unset($this->sections[$sectionName][$key]); } } diff --git a/system/bootstrap.php b/system/bootstrap.php index 4694de4..33ab455 100644 --- a/system/bootstrap.php +++ b/system/bootstrap.php @@ -8,7 +8,7 @@ * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology - * Copyright (c) 2019 CodeIgniter Foundation + * Copyright (c) 2019-2020 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ * * @package CodeIgniter * @author CodeIgniter Dev Team - * @copyright 2019 CodeIgniter Foundation + * @copyright 2019-2020 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 diff --git a/tests/_support/Models/ValidModel.php b/tests/_support/Models/ValidModel.php index 69842d8..dc9ec7c 100644 --- a/tests/_support/Models/ValidModel.php +++ b/tests/_support/Models/ValidModel.php @@ -22,7 +22,7 @@ 'required', 'min_length[3]', ], - 'token' => 'in_list[{id}]', + 'token' => 'permit_empty|in_list[{id}]', ]; protected $validationMessages = [