]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Improve precision in show command output parser
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 17 Apr 2023 07:49:28 +0000 (09:49 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 20 Apr 2023 10:00:26 +0000 (12:00 +0200)
gui/baculum/protected/API/Modules/ConsoleOutputShowPage.php

index a7e280568ba7b49fe13d9174396574467c3b94a3..6eb80d09c08abd27f4105bf62f640cce6cf690eb 100644 (file)
@@ -75,11 +75,16 @@ abstract class ConsoleOutputShowPage extends ConsoleOutputPage {
                $ret = $part = [];
                $section = '';
                for ($i = 0; $i < count($output); $i++) {
-                       $scount = preg_match('/^[A-Za-z]+: name=.+/i', $output[$i], $match);
+                       $scount = preg_match('/^[A-Za-z]+: name=.+/i', $output[$i]);
                        $mcount = preg_match_all('/(?<=\s)\w+=.*?(?=\s+\w+=.*?|$)/i', $output[$i], $matches);
+                       $acount = preg_match('/^\s+-->\s+(\w+):\s+name=(.+?)(?=\s+\w+=.+|$)/i', $output[$i], $match);
                        if ($mcount == 0) {
                                continue;
                        }
+                       if ($acount == 1) {
+                               $key = strtolower($match[1]);
+                               $part[$key] = $match[2];
+                       }
                        for ($j = 0; $j < count($matches[0]); $j++) {
                                list($key, $value) = explode('=', $matches[0][$j], 2);
                                $key = strtolower($key);