[Pkg-owncloud-commits] [owncloud] 15/83: Removing trailing dot in path that samba doesn't seem to like
David Prévot
taffit at moszumanska.debian.org
Wed Dec 18 13:05:25 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch 5.0
in repository owncloud.
commit 321a1062d196d2ad150a012ff00496f9c69c38d4
Author: Vincent Petry <pvince81 at owncloud.com>
Date: Thu Nov 14 16:52:00 2013 +0100
Removing trailing dot in path that samba doesn't seem to like
Fixes #5778
Added unit test for getId() and constructUrl()
Backport of f66ec8a02271e73755cb965107eca60f027ffe78
---
apps/files_external/lib/smb.php | 7 ++++-
apps/files_external/tests/smbfunctions.php | 41 ++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index fede9fe..0168fa3 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -47,8 +47,13 @@ class SMB extends \OC\Files\Storage\StreamWrapper{
public function constructUrl($path) {
if (substr($path, -1)=='/') {
- $path=substr($path, 0, -1);
+ $path = substr($path, 0, -1);
}
+ if (substr($path, 0, 1)=='/') {
+ $path = substr($path, 1);
+ }
+ // remove trailing dots which some versions of samba don't seem to like
+ $path = rtrim($path, '.');
$path = urlencode($path);
$user = urlencode($this->user);
$pass = urlencode($this->password);
diff --git a/apps/files_external/tests/smbfunctions.php b/apps/files_external/tests/smbfunctions.php
new file mode 100644
index 0000000..749906d
--- /dev/null
+++ b/apps/files_external/tests/smbfunctions.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Copyright (c) 2013 Vincent Petry <pvince81 at owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Files\Storage;
+
+class SMBFunctions extends \PHPUnit_Framework_TestCase {
+
+ public function setUp() {
+ $id = uniqid();
+ // dummy config
+ $this->config = array(
+ 'run'=>false,
+ 'user'=>'test',
+ 'password'=>'testpassword',
+ 'host'=>'smbhost',
+ 'share'=>'/sharename',
+ 'root'=>'/rootdir/',
+ );
+
+ $this->instance = new \OC\Files\Storage\SMB($this->config);
+ }
+
+ public function tearDown() {
+ }
+
+ public function testGetId() {
+ $this->assertEquals('smb::test at smbhost//sharename//rootdir/', $this->instance->getId());
+ }
+
+ public function testConstructUrl() {
+ $this->assertEquals("smb://test:testpassword@smbhost/sharename/rootdir/abc", $this->instance->constructUrl('/abc'));
+ $this->assertEquals("smb://test:testpassword@smbhost/sharename/rootdir/abc", $this->instance->constructUrl('/abc/'));
+ $this->assertEquals("smb://test:testpassword@smbhost/sharename/rootdir/abc%2F", $this->instance->constructUrl('/abc/.'));
+ $this->assertEquals("smb://test:testpassword@smbhost/sharename/rootdir/abc%2Fdef", $this->instance->constructUrl('/abc/def'));
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list