Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,35 +429,44 @@ 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';

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);
}

Expand Down
13 changes: 7 additions & 6 deletions app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,24 @@ 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') {
$class = new $provider->class;
return $class->getResults($query, $provider);
}

abort(404, 'Provider type not supported');}
abort(404, 'Provider type not supported');
}
}
14 changes: 14 additions & 0 deletions app/Services/CustomFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

return [

'version' => '2.7.3',
'version' => '2.7.4',

'appsource' => env('APP_SOURCE', 'https://appslist.heimdall.site/'),

Expand Down
18 changes: 0 additions & 18 deletions tests/Feature/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}