From dc748a67a25b95221eb58711dc17ad7639fbb387 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Mon, 17 Apr 2023 09:49:28 +0200 Subject: [PATCH] baculum: Improve precision in show command output parser --- .../protected/API/Modules/ConsoleOutputShowPage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gui/baculum/protected/API/Modules/ConsoleOutputShowPage.php b/gui/baculum/protected/API/Modules/ConsoleOutputShowPage.php index a7e280568..6eb80d09c 100644 --- a/gui/baculum/protected/API/Modules/ConsoleOutputShowPage.php +++ b/gui/baculum/protected/API/Modules/ConsoleOutputShowPage.php @@ -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); -- 2.47.3