From dcd6f5153b7e7e6d798d5a77af65b7460f152e5c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 14 Dec 2016 18:14:35 +0200 Subject: Isolate CI_Security instantiation from CI_Input; improve tests --- system/core/CodeIgniter.php | 4 ++-- system/core/Input.php | 7 +++---- system/core/Utf8.php | 10 +++++----- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index dfc90af2a..410b9613b 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -243,7 +243,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * Instantiate the UTF-8 class * ------------------------------------------------------ */ - $UNI =& load_class('Utf8', 'core'); + $UNI =& load_class('Utf8', 'core', $charset); /* * ------------------------------------------------------ @@ -288,7 +288,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * Load the Input class and sanitize globals * ------------------------------------------------------ */ - $IN =& load_class('Input', 'core'); + $IN =& load_class('Input', 'core', $SEC); /* * ------------------------------------------------------ diff --git a/system/core/Input.php b/system/core/Input.php index aefc3b7d8..d881e253d 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -113,11 +113,10 @@ class CI_Input { * * @return void */ - public function __construct() + public function __construct(CI_Security &$security) { - $this->_enable_csrf = (config_item('csrf_protection') === TRUE); - - $this->security =& load_class('Security', 'core'); + $this->_enable_csrf = (config_item('csrf_protection') === TRUE); + $this->security = $security; // CSRF Protection check if ($this->_enable_csrf === TRUE && ! is_cli()) diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 93c611675..042ca4316 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -57,13 +57,13 @@ class CI_Utf8 { * * @return void */ - public function __construct() + public function __construct($charset) { if ( - defined('PREG_BAD_UTF8_ERROR') // PCRE must support UTF-8 - && (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE) // iconv or mbstring must be installed - && strtoupper(config_item('charset')) === 'UTF-8' // Application charset must be UTF-8 - ) + defined('PREG_BAD_UTF8_ERROR') // PCRE must support UTF-8 + && (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE) // iconv or mbstring must be installed + && $charset === 'UTF-8' // Application charset must be UTF-8 + ) { define('UTF8_ENABLED', TRUE); log_message('info', 'UTF-8 Support Enabled'); -- cgit v1.2.3-24-g4f1b