mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Fix searching for an empty string
Return all packages when an empty search term is used with keyword search. Reported-by: G. Schlisio <g.schlisio@dukun.de> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
3b9cb66a1e
commit
8aa4c51dfb
1 changed files with 6 additions and 4 deletions
|
@ -602,7 +602,7 @@ function pkg_search_page($SID="") {
|
||||||
else {
|
else {
|
||||||
/* Search by name and description (default). */
|
/* Search by name and description (default). */
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$q_where .= "AND (";
|
$q_keywords = "";
|
||||||
$op = "";
|
$op = "";
|
||||||
|
|
||||||
foreach (str_getcsv($_GET['K'], ' ') as $term) {
|
foreach (str_getcsv($_GET['K'], ' ') as $term) {
|
||||||
|
@ -623,8 +623,8 @@ function pkg_search_page($SID="") {
|
||||||
}
|
}
|
||||||
|
|
||||||
$term = "%" . addcslashes($term, '%_') . "%";
|
$term = "%" . addcslashes($term, '%_') . "%";
|
||||||
$q_where .= $op . " (Packages.Name LIKE " . $dbh->quote($term) . " OR ";
|
$q_keywords .= $op . " (Packages.Name LIKE " . $dbh->quote($term) . " OR ";
|
||||||
$q_where .= "Description LIKE " . $dbh->quote($term) . ") ";
|
$q_keywords .= "Description LIKE " . $dbh->quote($term) . ") ";
|
||||||
|
|
||||||
$count++;
|
$count++;
|
||||||
if ($count >= 20) {
|
if ($count >= 20) {
|
||||||
|
@ -633,7 +633,9 @@ function pkg_search_page($SID="") {
|
||||||
$op = "AND ";
|
$op = "AND ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$q_where .= ") ";
|
if (!empty($q_keywords)) {
|
||||||
|
$q_where .= "AND (" . $q_keywords . ") ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue