Skip to content
Snippets Groups Projects
Commit 8ab40f19 authored by Vincent Petry's avatar Vincent Petry
Browse files

Removing trailing dot in path that samba doesn't seem to like

Fixes #5778
Added unit test for getId() and constructUrl()
parent a7962faa
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
<?php
/**
* Copyright (c) 2013 Vincent Petry <pvince81@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@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'));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment