diff options
author | Andrey Andreev <narf@devilix.net> | 2014-01-15 17:37:01 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-01-15 17:37:01 +0100 |
commit | 08fef7de41cb06785cdb1024769892d9510e6e6b (patch) | |
tree | a261799206ceb67124896c11b4b61b13eb726a83 | |
parent | d8b1ad31cf7ee205ddf3cf396b1d1bfa45af49fa (diff) |
Fix #2799 by adding conditional PCRE UTF-8 support to CI_URI::filter_uri()
Also did a tiny micro-optimization in the Utf8 class.
-rw-r--r-- | system/core/URI.php | 2 | ||||
-rw-r--r-- | system/core/Utf8.php | 2 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 3 |
3 files changed, 4 insertions, 3 deletions
diff --git a/system/core/URI.php b/system/core/URI.php index 3d6d202c0..c83b7a74f 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -320,7 +320,7 @@ class CI_URI { */ public function filter_uri($str) { - if ( ! empty($str) && ! empty($this->_permitted_uri_chars) && ! preg_match('/^['.$this->_permitted_uri_chars.']+$/i', $str)) + if ( ! empty($str) && ! empty($this->_permitted_uri_chars) && ! preg_match('/^['.$this->_permitted_uri_chars.']+$/i'.(UTF8_ENABLED ? 'u' : ''), $str)) { show_error('The URI you submitted has disallowed characters.', 400); } diff --git a/system/core/Utf8.php b/system/core/Utf8.php index a78616d40..828a8aeba 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -66,7 +66,7 @@ class CI_Utf8 { } if ( - @preg_match('/./u', 'é') === 1 // PCRE must support UTF-8 + defined('PREG_BAD_UTF8_ERROR') // PCRE must support UTF-8 && function_exists('iconv') // iconv must be installed && MB_ENABLED === TRUE // mbstring must be enabled && $charset === 'UTF-8' // Application charset must be UTF-8 diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a1dc3c1d1..4712ed87d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -391,7 +391,8 @@ Release Date: Not Released - :doc:`URI Library <libraries/uri>` changes include: - - Renamed method ``_filter_uri()`` to ``filter_uri()`` and removed the ``preg_quote()`` call from it. + - Added conditional PCRE UTF-8 support to the "invalid URI characters" check and removed the ``preg_quote()`` call from it to allow more flexibility. + - Renamed method ``_filter_uri()`` to ``filter_uri()``. - Changed private methods to protected so that MY_URI can override them. - Renamed internal method ``_parse_cli_args()`` to ``_parse_argv()``. - Renamed internal method ``_detect_uri()`` to ``_parse_request_uri()``. |