Skip to content
This repository
Browse code

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
Mark Story authored July 22, 2009
4  cake/basics.php
@@ -362,8 +362,8 @@ function am() {
362 362
  */
363 363
 	function env($key) {
364 364
 		if ($key == 'HTTPS') {
365  
-			if (isset($_SERVER) && !empty($_SERVER)) {
366  
-				return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on');
  365
+			if (isset($_SERVER['HTTPS'])) {
  366
+				return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
367 367
 			}
368 368
 			return (strpos(env('SCRIPT_URI'), 'https://') === 0);
369 369
 		}
17  cake/tests/cases/basics.test.php
@@ -94,11 +94,28 @@ function testEnv() {
94 94
 
95 95
 		$_SERVER = $_ENV = array();
96 96
 
  97
+		$this->assertFalse(env('HTTPS'));
  98
+
97 99
 		$_SERVER['HTTPS'] = 'on';
98 100
 		$this->assertTrue(env('HTTPS'));
99 101
 
  102
+		$_SERVER['HTTPS'] = '1';
  103
+		$this->assertTrue(env('HTTPS'));
  104
+
  105
+		$_SERVER['HTTPS'] = 'I am not empty';
  106
+		$this->assertTrue(env('HTTPS'));
  107
+
  108
+		$_SERVER['HTTPS'] = 1;
  109
+		$this->assertTrue(env('HTTPS'));
  110
+
100 111
 		$_SERVER['HTTPS'] = 'off';
101 112
 		$this->assertFalse(env('HTTPS'));
  113
+		
  114
+		$_SERVER['HTTPS'] = false;
  115
+		$this->assertFalse(env('HTTPS'));
  116
+		
  117
+		$_SERVER['HTTPS'] = '';
  118
+		$this->assertFalse(env('HTTPS'));
102 119
 
103 120
 		$_SERVER = array();
104 121
 

0 notes on commit 7ca8510

Please sign in to comment.
Something went wrong with that request. Please try again.