From 9c126572a2aebd43838aab9bf6abc09719ce983e Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sun, 17 Apr 2022 08:38:16 -0500 Subject: [PATCH] Fix validation page (#13929) * Validation web page fixes * Validation web page fixes * update baseline --- LibreNMS/Util/Html.php | 13 ------------- LibreNMS/ValidationResult.php | 6 +++--- phpstan-baseline.neon | 5 ----- resources/views/validate/index.blade.php | 10 +++------- tests/FunctionsTest.php | 18 ------------------ 5 files changed, 6 insertions(+), 46 deletions(-) diff --git a/LibreNMS/Util/Html.php b/LibreNMS/Util/Html.php index dbfaad25de..1d8a3a817a 100644 --- a/LibreNMS/Util/Html.php +++ b/LibreNMS/Util/Html.php @@ -136,19 +136,6 @@ class Html return $graph_data; } - /** - * Find all links in some text and turn them into html links. - * - * @param string|null $text - * @return string - */ - public static function linkify(?string $text): string - { - $regex = "#(http|https|ftp|ftps)://[a-z0-9\-.]*[a-z0-9\-]+(/\S*)?#i"; - - return preg_replace($regex, '$0', $text); - } - public static function percentageBar($width, $height, $percent, $left_text = '', $right_text = '', $warn = null, $shadow = null, $colors = null) { $percent = min($percent, 100); diff --git a/LibreNMS/ValidationResult.php b/LibreNMS/ValidationResult.php index 73144427b9..6164bdf9b1 100644 --- a/LibreNMS/ValidationResult.php +++ b/LibreNMS/ValidationResult.php @@ -25,7 +25,7 @@ namespace LibreNMS; -use LibreNMS\Util\Html; +use Illuminate\Support\Arr; class ValidationResult { @@ -223,9 +223,9 @@ class ValidationResult return [ 'status' => $resultStatus, - 'statusText' => $this->getStatusText($resultStatus), + 'statusText' => substr($this->getStatusText($resultStatus), 2, -2), // remove console colors 'message' => $this->getMessage(), - 'fix' => is_array($resultFix) ? $resultFix : ($resultList ? [Html::linkify($resultFix)] : []), + 'fix' => Arr::wrap($resultFix), 'listDescription' => $this->getListDescription(), 'list' => is_array($resultList) ? array_values($resultList) : [], ]; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ab5e751a68..832d9b4dd1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -11235,11 +11235,6 @@ parameters: count: 1 path: tests/FunctionsTest.php - - - message: "#^Method LibreNMS\\\\Tests\\\\FunctionsTest\\:\\:testLinkify\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/FunctionsTest.php - - message: "#^Method LibreNMS\\\\Tests\\\\FunctionsTest\\:\\:testMacCleanToReadable\\(\\) has no return type specified\\.$#" count: 1 diff --git a/resources/views/validate/index.blade.php b/resources/views/validate/index.blade.php index d6a1f844f3..ad70ea2c92 100644 --- a/resources/views/validate/index.blade.php +++ b/resources/views/validate/index.blade.php @@ -32,18 +32,14 @@