summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-06-08 21:33:11 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-06-08 21:35:52 +0200
commit8aa4c51dfb0baab7204f13da23618569dc1c7162 (patch)
tree789265c06b5a45cd43b5eee6aa9eb45d33b6aee6 /web/lib
parent3b9cb66a1e417fe68fa44ac6eb24c5ee2c6a0bc4 (diff)
downloadaur-8aa4c51dfb0baab7204f13da23618569dc1c7162.tar.gz
aur-8aa4c51dfb0baab7204f13da23618569dc1c7162.tar.xz
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>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgfuncs.inc.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index ee63e422..11785503 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -602,7 +602,7 @@ function pkg_search_page($SID="") {
else {
/* Search by name and description (default). */
$count = 0;
- $q_where .= "AND (";
+ $q_keywords = "";
$op = "";
foreach (str_getcsv($_GET['K'], ' ') as $term) {
@@ -623,8 +623,8 @@ function pkg_search_page($SID="") {
}
$term = "%" . addcslashes($term, '%_') . "%";
- $q_where .= $op . " (Packages.Name LIKE " . $dbh->quote($term) . " OR ";
- $q_where .= "Description LIKE " . $dbh->quote($term) . ") ";
+ $q_keywords .= $op . " (Packages.Name LIKE " . $dbh->quote($term) . " OR ";
+ $q_keywords .= "Description LIKE " . $dbh->quote($term) . ") ";
$count++;
if ($count >= 20) {
@@ -633,7 +633,9 @@ function pkg_search_page($SID="") {
$op = "AND ";
}
- $q_where .= ") ";
+ if (!empty($q_keywords)) {
+ $q_where .= "AND (" . $q_keywords . ") ";
+ }
}
}