Skip to content

Commit 1ae6804

Browse files
committed
Allow hidden smb shares
A hidden smb share ends with $. This patch changes the placeholder detection to allow shares with $ at the end. Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
1 parent 685f00c commit 1ae6804

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

apps/files_external/lib/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static function arePlaceholdersSubstituted($option):bool {
292292
}
293293
}
294294
} else if (is_string($option)) {
295-
if (strpos($option, '$') !== false) {
295+
if (strpos(rtrim($option, '$'), '$') !== false) {
296296
$result = false;
297297
}
298298
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de>
4+
*
5+
* @author Daniel Kesselberg <mail@danielkesselberg.de>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OCA\files_external\tests\Config;
25+
26+
use OC_Mount_Config;
27+
use Test\TestCase;
28+
29+
class PlaceholderSubstituteTest extends TestCase {
30+
31+
public function dataArePlaceholdersSubstituted(): array {
32+
return [
33+
['smb_$user', false],
34+
['hidden_share$', true],
35+
];
36+
}
37+
38+
/**
39+
* @dataProvider dataArePlaceholdersSubstituted
40+
* @param string|array $option
41+
* @param bool $expected
42+
*/
43+
public function testArePlaceholdersSubstituted($option, $expected): void {
44+
$this->assertSame($expected, OC_Mount_Config::arePlaceholdersSubstituted($option));
45+
}
46+
47+
}

0 commit comments

Comments
 (0)