From ae55b4794ffd233d4f2cd4b36a29e48d2724b244 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 20 Mar 2022 18:22:12 -0600 Subject: [PATCH] Fix for multi-lang issues with Security report --- CHANGELOG.md | 1 + system/src/Grav/Common/Security.php | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c05689659..4f0e1115f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - `text` (multiline), `textarea`: 65536 3. [](#bugfix) * Fixed issue with `system.cache.gzip: true` resulted in admin "Fetch Failed" for PHP 8.0+ + * Fix for multi-lang issues with Security Report # v1.7.31 ## 03/14/2022 diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php index 779e61918..11153a625 100644 --- a/system/src/Grav/Common/Security.php +++ b/system/src/Grav/Common/Security.php @@ -97,7 +97,7 @@ class Security */ public static function detectXssFromPages(Pages $pages, $route = true, callable $status = null) { - $routes = $pages->routes(); + $routes = $pages->getList(null, 0, true); // Remove duplicate for homepage unset($routes['/']); @@ -110,26 +110,23 @@ class Security 'steps' => count($routes), ]); - foreach ($routes as $path) { + foreach (array_keys($routes) as $route) { $status && $status([ 'type' => 'progress', ]); try { - $page = $pages->get($path); + $page = $pages->find($route); + if ($page->exists()) { + // call the content to load/cache it + $header = (array) $page->header(); + $content = $page->value('content'); - // call the content to load/cache it - $header = (array) $page->header(); - $content = $page->value('content'); + $data = ['header' => $header, 'content' => $content]; + $results = static::detectXssFromArray($data); - $data = ['header' => $header, 'content' => $content]; - $results = static::detectXssFromArray($data); - - if (!empty($results)) { - if ($route) { - $list[$page->route()] = $results; - } else { - $list[$page->filePathClean()] = $results; + if (!empty($results)) { + $list[$page->rawRoute()] = $results; } } } catch (Exception $e) {