Quellcode durchsuchen

Added path detection fix for Windows specific dirname() path separator use - fixes ZF-6860

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18283 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic vor 16 Jahren
Ursprung
Commit
5beb1e0d2c

+ 1 - 1
library/Zend/Service/Nirvanix/Namespace/Imfs.php

@@ -82,7 +82,7 @@ class Zend_Service_Nirvanix_Namespace_Imfs extends Zend_Service_Nirvanix_Namespa
         $this->_httpClient->resetParameters();
         $this->_httpClient->setUri("http://{$host}/Upload.ashx");
         $this->_httpClient->setParameterPost('uploadToken', $uploadToken);
-        $this->_httpClient->setParameterPost('destFolderPath', dirname($filePath));
+        $this->_httpClient->setParameterPost('destFolderPath', str_replace('\\', '/',dirname($filePath)));
         $this->_httpClient->setFileUpload(basename($filePath), 'uploadFile', $data, $mimeType);
         $response = $this->_httpClient->request(Zend_Http_Client::POST);
 

+ 29 - 18
tests/Zend/Service/Nirvanix/Namespace/ImfsTest.php

@@ -19,7 +19,7 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id$
  */
- 
+
 /**
  * @see Zend_Service_Nirvanix_Namespace_Imfs
  */
@@ -46,9 +46,9 @@ class Zend_Service_Nirvanix_Namespace_ImfsTest extends Zend_Service_Nirvanix_Fun
         $imfs = new Zend_Service_Nirvanix_Namespace_Imfs();
         $this->assertType('Zend_Service_Nirvanix_Namespace_Base', $imfs);
     }
-    
+
     // putContents()
-    
+
     public function testPutContents()
     {
         $imfs = $this->nirvanix->getService('IMFS');
@@ -59,23 +59,23 @@ class Zend_Service_Nirvanix_Namespace_ImfsTest extends Zend_Service_Nirvanix_Fun
                 array('ResponseCode'   => '0',
                       'GetStorageNode' => '<UploadHost>node1.nirvanix.com</UploadHost>
                                            <UploadToken>bar</UploadToken>'))
-        );        
+        );
 
         $imfs->putContents('/foo', 'contents for foo');
-    }    
-    
+    }
+
     // getContents()
-    
+
     public function testGetContents()
     {
         $imfs = $this->nirvanix->getService('IMFS');
-        
+
         // response for call to GetOptimalUrlss
         $this->httpAdapter->addResponse(
            $this->makeNirvanixResponse(
                 array('ResponseCode' => '0',
                       'Download' => '<DownloadURL>http://get-it-here</DownloadURL>'))
-        );              
+        );
 
         // response for file download
         $this->httpAdapter->addResponse(
@@ -86,9 +86,9 @@ class Zend_Service_Nirvanix_Namespace_ImfsTest extends Zend_Service_Nirvanix_Fun
         $expected = $this->httpClient->getLastResponse()->getBody();
         $this->assertEquals($expected, $actual);
     }
-    
+
     // unlink()
-    
+
     public function testUnlink()
     {
         $imfs = $this->nirvanix->getService('IMFS');
@@ -96,15 +96,26 @@ class Zend_Service_Nirvanix_Namespace_ImfsTest extends Zend_Service_Nirvanix_Fun
         // response for call to DeleteFiles
         $this->httpAdapter->addResponse(
             $this->makeNirvanixResponse(array('ResponseCode' => '0'))
-        );        
+        );
 
         $imfs->unlink('foo');
     }
 
-}
-
-
-
-
-
+    /**
+     * @issue ZF-6860
+     */
+    public function testDestinationPathFormatSentToServiceAsParameterUsesUnixConvention()
+    {
+        $imfs = $this->nirvanix->getService('IMFS');
+        $this->httpAdapter->addResponse(
+           $this->makeNirvanixResponse(
+                array('ResponseCode'   => '0',
+                      'GetStorageNode' => '<UploadHost>node1.nirvanix.com</UploadHost>
+                                           <UploadToken>bar</UploadToken>'))
+        );
+        // little unix cheat to force a backslash into the IFS path
+        $imfs->putContents('.\foo/bar', 'contents for foo');
+        $this->assertContains('./foo', $imfs->getHttpClient()->getLastRequest());
+    }
 
+}