]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix uploading files containing a # in the path for webdav
authorRobin Appelman <icewind@owncloud.com>
Mon, 31 Mar 2014 15:00:32 +0000 (17:00 +0200)
committerRobin Appelman <icewind@owncloud.com>
Mon, 31 Mar 2014 15:00:32 +0000 (17:00 +0200)
apps/files_external/lib/webdav.php
tests/lib/files/storage/storage.php

index 279ae716935994411e889bbadef270ecf362ef97..f5010f92208d76a5b87f288dac3af854dcde3b64 100644 (file)
@@ -267,7 +267,7 @@ class DAV extends \OC\Files\Storage\Common {
 
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_USERPWD, $this->user . ':' . $this->password);
-               curl_setopt($curl, CURLOPT_URL, $this->createBaseUri() . str_replace(' ', '%20', $target));
+               curl_setopt($curl, CURLOPT_URL, $this->createBaseUri() . $this->encodePath($target));
                curl_setopt($curl, CURLOPT_BINARYTRANSFER, true);
                curl_setopt($curl, CURLOPT_INFILE, $source); // file pointer
                curl_setopt($curl, CURLOPT_INFILESIZE, filesize($path));
index f3bfba3feb8e64171464b315ab283904d16dbf94..e4d9e93ca975c370331687b80a048a14a070b9d6 100644 (file)
@@ -299,7 +299,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
                $this->assertFalse($this->instance->file_exists('folder'));
        }
 
-       public function hashProvider(){
+       public function hashProvider() {
                return array(
                        array('Foobar', 'md5'),
                        array('Foobar', 'sha1'),
@@ -315,4 +315,23 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
                $this->assertEquals(hash($type, $data), $this->instance->hash($type, 'hash.txt'));
                $this->assertEquals(hash($type, $data, true), $this->instance->hash($type, 'hash.txt', true));
        }
+
+       public function testHashInFileName() {
+               $this->instance->file_put_contents('#test.txt', 'data');
+               $this->assertEquals('data', $this->instance->file_get_contents('#test.txt'));
+
+               $this->instance->mkdir('#foo');
+               $this->instance->file_put_contents('#foo/test.txt', 'data');
+               $this->assertEquals('data', $this->instance->file_get_contents('#foo/test.txt'));
+
+               $dh = $this->instance->opendir('#foo');
+               $content = array();
+               while ($file = readdir($dh)) {
+                       if ($file != '.' and $file != '..') {
+                               $content[] = $file;
+                       }
+               }
+
+               $this->assertEquals(array('test.txt'), $content);
+       }
 }