]> source.dussan.org Git - nextcloud-server.git/commitdiff
support string values ('true' and 'false') for configuring the secure parameter on...
authorRobin Appelman <icewind@owncloud.com>
Mon, 5 Nov 2012 15:39:03 +0000 (16:39 +0100)
committerRobin Appelman <icewind@owncloud.com>
Mon, 5 Nov 2012 15:46:47 +0000 (16:46 +0100)
fixes #78

apps/files_external/lib/ftp.php
apps/files_external/lib/swift.php
apps/files_external/lib/webdav.php
apps/files_external/tests/ftp.php

index 261141455cce8752add3be7627dd4cb3d6ae9836..da4feac76826a6f9958bb8a43d789b19f7feaaa7 100644 (file)
@@ -19,7 +19,15 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
                $this->host=$params['host'];
                $this->user=$params['user'];
                $this->password=$params['password'];
-               $this->secure=isset($params['secure'])?(bool)$params['secure']:false;
+               if(isset($params['secure'])){
+                       if(is_string($params['secure'])){
+                               $this->secure = ($params['secure'] === 'true');
+                       }else{
+                               $this->secure = (bool)$params['secure'];
+                       }
+               }else{
+                       $this->secure = false;
+               }
                $this->root=isset($params['root'])?$params['root']:'/';
                if(!$this->root || $this->root[0]!='/') {
                        $this->root='/'.$this->root;
index 4b0b8c25fda50a16469ebe91352e739aa44faf53..3268a6165d5e651f9a760f47b95e8e77981f119c 100644 (file)
@@ -271,7 +271,15 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
                $this->host=$params['host'];
                $this->user=$params['user'];
                $this->root=isset($params['root'])?$params['root']:'/';
-               $this->secure=isset($params['secure'])?(bool)$params['secure']:true;
+               if(isset($params['secure'])){
+                       if(is_string($params['secure'])){
+                               $this->secure = ($params['secure'] === 'true');
+                       }else{
+                               $this->secure = (bool)$params['secure'];
+                       }
+               }else{
+                       $this->secure = false;
+               }
                if(!$this->root || $this->root[0]!='/') {
                        $this->root='/'.$this->root;
                }
index 5e1858391588925a6617b0218a76a72cfe1bf602..38214d58a807d5576797cb345c7ede65002a8b58 100644 (file)
@@ -27,7 +27,15 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
                $this->host=$host;
                $this->user=$params['user'];
                $this->password=$params['password'];
-               $this->secure=(isset($params['secure']) && $params['secure'] == 'true')?true:false;
+               if(isset($params['secure'])){
+                       if(is_string($params['secure'])){
+                               $this->secure = ($params['secure'] === 'true');
+                       }else{
+                               $this->secure = (bool)$params['secure'];
+                       }
+               }else{
+                       $this->secure = false;
+               }
                $this->root=isset($params['root'])?$params['root']:'/';
                if(!$this->root || $this->root[0]!='/') {
                        $this->root='/'.$this->root;
index 4549c4204101903ffca58c24bc38706bb40a05ad..80288b591141a6697d1f283ab62af5ae1f3c7538 100644 (file)
@@ -24,4 +24,22 @@ class Test_Filestorage_FTP extends Test_FileStorage {
                        OCP\Files::rmdirr($this->instance->constructUrl(''));
                }
        }
+
+       public function testConstructUrl(){
+               $config = array ( 'host' => 'localhost', 'user' => 'ftp', 'password' => 'ftp', 'root' => '/', 'secure' => false );
+               $instance = new OC_Filestorage_FTP($config);
+               $this->assertEqual('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
+
+               $config['secure'] = true;
+               $instance = new OC_Filestorage_FTP($config);
+               $this->assertEqual('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
+
+               $config['secure'] = 'false';
+               $instance = new OC_Filestorage_FTP($config);
+               $this->assertEqual('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
+
+               $config['secure'] = 'true';
+               $instance = new OC_Filestorage_FTP($config);
+               $this->assertEqual('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
+       }
 }