From b6ed3d102dc7c8e2a591405e56aa780d64d385d6 Mon Sep 17 00:00:00 2001 From: Vivek Dinesh Date: Thu, 11 Aug 2016 17:40:45 +0530 Subject: URI schemes are not case-sensitive Signed-off-by: Vivek Dinesh --- system/helpers/url_helper.php | 2 +- system/libraries/Form_validation.php | 4 ++-- system/libraries/Javascript.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index fd7b5e116..82b9e02af 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -443,7 +443,7 @@ if ( ! function_exists('prep_url')) */ function prep_url($str = '') { - if ($str === 'http://' OR $str === '') + if (strtolower($str) === 'http://' OR $str === '') { return ''; } diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 61f0298fd..fa28a6207 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1523,12 +1523,12 @@ class CI_Form_validation { */ public function prep_url($str = '') { - if ($str === 'http://' OR $str === '') + if (strtolower($str) === 'http://' OR $str === '') { return ''; } - if (strpos($str, 'http://') !== 0 && strpos($str, 'https://') !== 0) + if (stripos($str, 'http://') !== 0 && stripos($str, 'https://') !== 0) { return 'http://'.$str; } diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index dcf933779..2ddab38ee 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -650,11 +650,11 @@ class CI_Javascript { $this->_javascript_location = $this->CI->config->item('javascript_location'); } - if ($relative === TRUE OR strpos($external_file, 'http://') === 0 OR strpos($external_file, 'https://') === 0) + if ($relative === TRUE OR stripos($external_file, 'http://') === 0 OR stripos($external_file, 'https://') === 0) { $str = $this->_open_script($external_file); } - elseif (strpos($this->_javascript_location, 'http://') !== FALSE) + elseif (stripos($this->_javascript_location, 'http://') !== FALSE) { $str = $this->_open_script($this->_javascript_location.$external_file); } -- cgit v1.2.3-24-g4f1b From 669cc5f881970ec3cc19b57f4da0382c7d8f5542 Mon Sep 17 00:00:00 2001 From: Vivek Dinesh Date: Thu, 11 Aug 2016 18:21:11 +0530 Subject: Removed useless checks Based on GitHub discussion. Signed-off-by: Vivek Dinesh --- system/helpers/url_helper.php | 2 +- system/libraries/Form_validation.php | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 82b9e02af..8a5a75c44 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -443,7 +443,7 @@ if ( ! function_exists('prep_url')) */ function prep_url($str = '') { - if (strtolower($str) === 'http://' OR $str === '') + if ($str === '') { return ''; } diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index fa28a6207..86a569ced 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1523,12 +1523,7 @@ class CI_Form_validation { */ public function prep_url($str = '') { - if (strtolower($str) === 'http://' OR $str === '') - { - return ''; - } - - if (stripos($str, 'http://') !== 0 && stripos($str, 'https://') !== 0) + if ($str !== '' && stripos($str, 'http://') !== 0 && stripos($str, 'https://') !== 0) { return 'http://'.$str; } -- cgit v1.2.3-24-g4f1b