From 8840c96cc0608859ad4b5341c31db9bb1f833792 Mon Sep 17 00:00:00 2001 From: freewil Date: Sun, 18 Mar 2012 15:23:09 -0400 Subject: use php's hash() function for do_hash() helper --- system/helpers/security_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/security_helper.php') diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index e05e947a5..16dfb0de3 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -87,7 +87,7 @@ if ( ! function_exists('do_hash')) { function do_hash($str, $type = 'sha1') { - return ($type === 'sha1') ? sha1($str) : md5($str); + return hash($type, $str); } } -- cgit v1.2.3-24-g4f1b From 50bff7c06c177f580db956ef5df9a490141de5f6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Mar 2012 12:16:38 +0200 Subject: Fix possible error messages with do_hash() and alter a changelog entry --- system/helpers/security_helper.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'system/helpers/security_helper.php') diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 16dfb0de3..2f3df7834 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Security Helpers * @@ -42,7 +40,6 @@ /** * XSS Filtering * - * @access public * @param string * @param bool whether or not the content is an image file * @return string @@ -61,7 +58,6 @@ if ( ! function_exists('xss_clean')) /** * Sanitize Filename * - * @access public * @param string * @return string */ @@ -79,7 +75,6 @@ if ( ! function_exists('sanitize_filename')) /** * Hash encode a string * - * @access public * @param string * @return string */ @@ -87,6 +82,11 @@ if ( ! function_exists('do_hash')) { function do_hash($str, $type = 'sha1') { + if ( ! in_array($type, hash_algos())) + { + $type = 'md5'; + } + return hash($type, $str); } } @@ -96,7 +96,6 @@ if ( ! function_exists('do_hash')) /** * Strip Image Tags * - * @access public * @param string * @return string */ @@ -104,7 +103,7 @@ if ( ! function_exists('strip_image_tags')) { function strip_image_tags($str) { - return preg_replace(array("##", "##"), "\\1", $str); + return preg_replace(array('##', '##'), '\\1', $str); } } @@ -113,7 +112,6 @@ if ( ! function_exists('strip_image_tags')) /** * Convert PHP tags to entities * - * @access public * @param string * @return string */ -- cgit v1.2.3-24-g4f1b From 7eea3064af3be5dd0b526056211a510f90a40766 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Mar 2012 12:58:45 +0200 Subject: Apply strtolower() to hash support check in do_hash() --- system/helpers/security_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/security_helper.php') diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 2f3df7834..8c7adea46 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -82,7 +82,7 @@ if ( ! function_exists('do_hash')) { function do_hash($str, $type = 'sha1') { - if ( ! in_array($type, hash_algos())) + if ( ! in_array(strtolower($type), hash_algos())) { $type = 'md5'; } -- cgit v1.2.3-24-g4f1b