From f247892b3b8126c38d5fbfde365d210be8235c32 Mon Sep 17 00:00:00 2001 From: J0WI Date: Thu, 11 Feb 2021 16:36:27 +0100 Subject: [PATCH] Match any non-whitespace character in filesystem type pattern Signed-off-by: J0WI --- lib/OperatingSystems/DefaultOs.php | 2 +- tests/data/df_tp | 1 + tests/lib/DefaultOsTest.php | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/OperatingSystems/DefaultOs.php b/lib/OperatingSystems/DefaultOs.php index 297940bd..2fd04529 100644 --- a/lib/OperatingSystems/DefaultOs.php +++ b/lib/OperatingSystems/DefaultOs.php @@ -212,7 +212,7 @@ public function getDiskInfo(): array { } $matches = []; - $pattern = '/^(?[\S]+)\s*(?\w+)\s*(?\d+)\s*(?\d+)\s*(?\d+)\s*(?\d+%)\s*(?[\w\/-]+)$/m'; + $pattern = '/^(?[\S]+)\s*(?[\S]+)\s*(?\d+)\s*(?\d+)\s*(?\d+)\s*(?\d+%)\s*(?[\w\/-]+)$/m'; $result = preg_match_all($pattern, $disks, $matches); if ($result === 0 || $result === false) { diff --git a/tests/data/df_tp b/tests/data/df_tp index 4d9cbb36..c330e565 100644 --- a/tests/data/df_tp +++ b/tests/data/df_tp @@ -10,3 +10,4 @@ vagrant vboxsf 958123168 614831132 343292036 home_vagrant_code vboxsf 958123168 614831132 343292036 65% /home/vagrant/code tmpfs tmpfs 816800 0 816800 0% /run/user/1000 nfs.example.com:/export nfs4 14820 0 1230 0% /nfs +198.51.100.42:/storage fuse.sshfs 47929956 53116 45419052 1% /mnt/sshfs diff --git a/tests/lib/DefaultOsTest.php b/tests/lib/DefaultOsTest.php index f7b3208f..77eedff9 100644 --- a/tests/lib/DefaultOsTest.php +++ b/tests/lib/DefaultOsTest.php @@ -178,6 +178,14 @@ public function testGetDiskInfo(): void { 'available' => 1259520, 'percent' => '0%', 'mount' => '/nfs', + ], + [ + 'device' => '198.51.100.42:/storage', + 'fs' => 'fuse.sshfs', + 'used' => 54390784, + 'available' => 46509109248, + 'percent' => '1%', + 'mount' => '/mnt/sshfs', ] ];