mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-16 03:43:48 +09:00
Redirect to search provider without error fixes #1482
This commit is contained in:
@@ -21,17 +21,17 @@ class SearchController extends Controller
|
|||||||
// Sanitize the query to prevent XSS
|
// Sanitize the query to prevent XSS
|
||||||
$query = htmlspecialchars($query, ENT_QUOTES, 'UTF-8');
|
$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);
|
$provider = Search::providerDetails($requestprovider);
|
||||||
|
|
||||||
if (!$provider || !isset($provider->type)) {
|
if (!$provider || !isset($provider->type)) {
|
||||||
abort(404, 'Invalid provider');
|
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') {
|
if ($provider->type == 'standard') {
|
||||||
return redirect($provider->url.'?'.$provider->query.'='.urlencode($query));
|
return redirect($provider->url.'?'.$provider->query.'='.urlencode($query));
|
||||||
} elseif ($provider->type == 'external') {
|
} elseif ($provider->type == 'external') {
|
||||||
@@ -39,5 +39,6 @@ class SearchController extends Controller
|
|||||||
return $class->getResults($query, $provider);
|
return $class->getResults($query, $provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
abort(404, 'Provider type not supported');}
|
abort(404, 'Provider type not supported');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user