Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating env(HTTPS); to more accurately reflect the PHP $_SERVER docs…

…. Fixes #6524

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8246 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 7ca85109cb6120df752d0a5043866a47143f89f6 1 parent d6a12ce
@markstory markstory authored
Showing with 19 additions and 2 deletions.
  1. +2 −2 cake/basics.php
  2. +17 −0 cake/tests/cases/basics.test.php
View
4 cake/basics.php
@@ -362,8 +362,8 @@ function am() {
*/
function env($key) {
if ($key == 'HTTPS') {
- if (isset($_SERVER) && !empty($_SERVER)) {
- return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on');
+ if (isset($_SERVER['HTTPS'])) {
+ return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
}
return (strpos(env('SCRIPT_URI'), 'https://') === 0);
}
View
17 cake/tests/cases/basics.test.php
@@ -94,11 +94,28 @@ function testEnv() {
$_SERVER = $_ENV = array();
+ $this->assertFalse(env('HTTPS'));
+
$_SERVER['HTTPS'] = 'on';
$this->assertTrue(env('HTTPS'));
+ $_SERVER['HTTPS'] = '1';
+ $this->assertTrue(env('HTTPS'));
+
+ $_SERVER['HTTPS'] = 'I am not empty';
+ $this->assertTrue(env('HTTPS'));
+
+ $_SERVER['HTTPS'] = 1;
+ $this->assertTrue(env('HTTPS'));
+
$_SERVER['HTTPS'] = 'off';
$this->assertFalse(env('HTTPS'));
+
+ $_SERVER['HTTPS'] = false;
+ $this->assertFalse(env('HTTPS'));
+
+ $_SERVER['HTTPS'] = '';
+ $this->assertFalse(env('HTTPS'));
$_SERVER = array();
Please sign in to comment.
Something went wrong with that request. Please try again.