Skip to content

A free open source IT asset/license management system

Fixed RB-22044 - check for string on asset type breadcrumbs

sniped2a37d661eef
diff --git a/app/Providers/BreadcrumbsServiceProvider.php b/app/Providers/BreadcrumbsServiceProvider.php
index c746c6bff0..16f0bb5080 100644
--- a/app/Providers/BreadcrumbsServiceProvider.php
+++ b/app/Providers/BreadcrumbsServiceProvider.php
@@ -45,10 +45,11 @@ class BreadcrumbsServiceProvider extends ServiceProvider
/**
* Asset Breadcrumbs
*/
- if ((request()->is('hardware*')) && (request()->status_type != '')) {
+ $statusType = request()->status_type;
+ if (request()->is('hardware*') && is_string($statusType) && $statusType !== '') {
Breadcrumbs::for('hardware.index', fn (Trail $trail) => $trail->parent('home', route('home'))
->push(trans('general.assets'), route('hardware.index'))
- ->push(trans('general.'.strtolower(e(request()->status_type))), route('hardware.index', ['status_type' => request()->status_type]))
+ ->push(trans('general.' . strtolower(e($statusType))), route('hardware.index', ['status_type' => $statusType]))
);
} else {
diff --git a/tests/Feature/Assets/Ui/AssetIndexTest.php b/tests/Feature/Assets/Ui/AssetIndexTest.php
index 3fcaa5990f..d30f734ead 100644
--- a/tests/Feature/Assets/Ui/AssetIndexTest.php
+++ b/tests/Feature/Assets/Ui/AssetIndexTest.php
@@ -25,4 +25,18 @@ class AssetIndexTest extends TestCase
]))
->assertOk();
}
+
+ public function test_page_renders_when_status_type_is_an_associative_array_probe()
+ {
+ // Regression pin for an array-shaped query probe like
+ // ?status_type[$ptt]=RTD. request()->status_type returns an
+ // associative array, the old breadcrumb branch compared it
+ // to '' (truthy for arrays), then passed it to e(), which
+ // crashed htmlspecialchars with a TypeError and surfaced as
+ // a ViewException on the whole /hardware page. The guard
+ // now requires is_string before the e() call.
+ $this->actingAs(User::factory()->superuser()->create())
+ ->get('/hardware?status_type[$ptt]=RTD')
+ ->assertOk();
+ }
}