Skip to content

Commit bfcd97b

Browse files
authored
Merge pull request #281 from nextcloud/backport/274/stable20
[stable20] Match any non-whitespace character in filesystem type pattern
2 parents 5861fc0 + b8c68a1 commit bfcd97b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lib/OperatingSystems/DefaultOs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function getDiskInfo(): array {
197197
}
198198

199199
$matches = [];
200-
$pattern = '/^(?<Filesystem>[\S]+)\s*(?<Type>\w+)\s*(?<Blocks>\d+)\s*(?<Used>\d+)\s*(?<Available>\d+)\s*(?<Capacity>\d+%)\s*(?<Mounted>[\w\/-]+)$/m';
200+
$pattern = '/^(?<Filesystem>[\S]+)\s*(?<Type>[\S]+)\s*(?<Blocks>\d+)\s*(?<Used>\d+)\s*(?<Available>\d+)\s*(?<Capacity>\d+%)\s*(?<Mounted>[\w\/-]+)$/m';
201201

202202
$result = preg_match_all($pattern, $disks, $matches);
203203
if ($result === 0 || $result === false) {

tests/data/df_tp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ vagrant vboxsf 958123168 614831132 343292036
1010
home_vagrant_code vboxsf 958123168 614831132 343292036 65% /home/vagrant/code
1111
tmpfs tmpfs 816800 0 816800 0% /run/user/1000
1212
nfs.example.com:/export nfs4 14820 0 1230 0% /nfs
13+
198.51.100.42:/storage fuse.sshfs 47929956 53116 45419052 1% /mnt/sshfs

tests/lib/DefaultOsTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,15 @@ public function testGetDiskInfo(): void {
174174
$disk5->setPercent('0%');
175175
$disk5->setMount('/nfs');
176176

177-
$this->assertEquals([$disk1, $disk2, $disk3, $disk4, $disk5], $this->os->getDiskInfo());
177+
$disk6 = new Disk();
178+
$disk6->setDevice('198.51.100.42:/storage');
179+
$disk6->setFs('fuse.sshfs');
180+
$disk6->setUsed(51);
181+
$disk6->setAvailable(44354);
182+
$disk6->setPercent('1%');
183+
$disk6->setMount('/mnt/sshfs');
184+
185+
$this->assertEquals([$disk1, $disk2, $disk3, $disk4, $disk5, $disk6], $this->os->getDiskInfo());
178186
}
179187

180188
public function testGetDiskInfoNoCommandOutput(): void {

0 commit comments

Comments
 (0)