diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index 7c0598fba..0d87ba297 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -429,20 +429,31 @@ public function appload(Request $request): ?string return null; } - $output['config'] = null; - $output['custom'] = null; - $app = Application::single($appid); + + if (!$app) { + return response()->json(['error' => 'Application not found.'], 404); + } + $output = (array)$app; $appdetails = Application::getApp($appid); + if (!$appdetails) { + return response()->json(['error' => 'Application details not found.'], 404); + } + if ((bool)$app->enhanced === true) { $item = $itemId ? Item::find($itemId) : Item::where('appid', $appid)->first(); - // if(!isset($app->config)) { // class based config - $output['custom'] = className($appdetails->name) . '.config'; - $output['appvalue'] = $item->description; - // } + + if ($item) { + $output['custom'] = className($appdetails->name) . '.config'; + $output['appvalue'] = $item->description; + } else { + // Ensure the app is installed if not found + $output['custom'] = className($appdetails->name) . '.config'; + $output['appvalue'] = null; + } } $output['colour'] = ($app->tile_background == 'light') ? '#fafbfc' : '#161b1f'; @@ -450,14 +461,12 @@ public function appload(Request $request): ?string if (strpos($app->icon, '://') !== false) { $output['iconview'] = $app->icon; } elseif (strpos($app->icon, 'icons/') !== false) { - // Private apps have the icon locally $output['iconview'] = URL::to('/') . '/storage/' . $app->icon; $output['icon'] = str_replace('icons/', '', $output['icon']); } else { $output['iconview'] = config('app.appsource') . 'icons/' . $app->icon; } - return json_encode($output); } diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 8a16e32b2..63d30eff4 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -21,17 +21,17 @@ public function index(Request $request) // Sanitize the query to prevent XSS $query = htmlspecialchars($query, ENT_QUOTES, 'UTF-8'); - // Validate the presence and non-emptiness of the query parameter - if (!$query || trim($query) === '') { - abort(400, 'Missing or empty query parameter'); - } - $provider = Search::providerDetails($requestprovider); if (!$provider || !isset($provider->type)) { abort(404, 'Invalid provider'); } + // If the query is empty, redirect to the provider's base URL + if (!$query || trim($query) === '') { + return redirect($provider->url); + } + if ($provider->type == 'standard') { return redirect($provider->url.'?'.$provider->query.'='.urlencode($query)); } elseif ($provider->type == 'external') { @@ -39,5 +39,6 @@ public function index(Request $request) return $class->getResults($query, $provider); } - abort(404, 'Provider type not supported');} + abort(404, 'Provider type not supported'); + } } diff --git a/app/Services/CustomFormBuilder.php b/app/Services/CustomFormBuilder.php index 8700982fb..1b8758d93 100644 --- a/app/Services/CustomFormBuilder.php +++ b/app/Services/CustomFormBuilder.php @@ -21,6 +21,20 @@ public function text($name, $value = null, $options = []) ); } + public function hidden($name, $value = null, $options = []) + { + return new HtmlString( + $this->html->input('hidden', $name, $value)->attributes($options) + ); + } + + public function checkbox($name, $value = null, $checked = false, $options = []) + { + return new HtmlString( + $this->html->checkbox($name, $value, $checked)->attributes($options) + ); + } + public function select($name, $list = [], $selected = null, $options = []) { return new HtmlString( diff --git a/config/app.php b/config/app.php index 583ad6956..097afdea4 100644 --- a/config/app.php +++ b/config/app.php @@ -5,7 +5,7 @@ return [ - 'version' => '2.7.3', + 'version' => '2.7.4', 'appsource' => env('APP_SOURCE', 'https://appslist.heimdall.site/'), diff --git a/tests/Feature/SearchTest.php b/tests/Feature/SearchTest.php index af72419a6..9f656c0c9 100644 --- a/tests/Feature/SearchTest.php +++ b/tests/Feature/SearchTest.php @@ -32,22 +32,4 @@ public function test_search_page_with_invalid_provider(): void $response->assertStatus(404); // Assert that the response status is 404 } - public function test_search_page_without_query_parameter(): void - { - $provider = 'google'; // Example provider - - $response = $this->get(route('search', ['provider' => $provider])); - - $response->assertStatus(400); // Assert that the response status is 400 (Bad Request) - } - - public function test_search_page_with_empty_query(): void - { - $provider = 'google'; // Example provider - $query = ''; // Empty search term - - $response = $this->get(route('search', ['provider' => $provider, 'q' => $query])); - - $response->assertStatus(400); // Assert that the response status is 400 (Bad Request) - } } \ No newline at end of file