Alexander Nicolaysen Sørnes : Guard against intensive searches
Chris Morgan
cmorgan at winehq.org
Fri Jul 18 10:14:50 CDT 2008
Module: appdb
Branch: master
Commit: 7be5d6bd34d5c9c2f78df084e8d824b111925dcb
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=7be5d6bd34d5c9c2f78df084e8d824b111925dcb
Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date: Thu Jul 10 01:03:26 2008 +0200
Guard against intensive searches
---
include/util.php | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/include/util.php b/include/util.php
index 6fe6c1c..3b6453d 100644
--- a/include/util.php
+++ b/include/util.php
@@ -427,7 +427,16 @@ function cleanupSearchWords($search_words)
Search for the first word in the search query */
function searchForApplicationPartial($sSearchWords)
{
+ /* This would yield too many results and stress MySQL */
+ if(strlen($sSearchWords) < 4)
+ return null;
+
$sSearchWords = cleanupSearchWords($sSearchWords);
+
+ /* The search string may have gotten shorter; even empty */
+ if(strlen($sSearchWords) < 4)
+ return null;
+
$aWords = explode(' ', $sSearchWords);
$sSearchString = '';
$sEnsureExactWord = ''; // Used to ensure we don't match partial words when prepending
@@ -455,9 +464,17 @@ function searchForApplicationPartial($sSearchWords)
/* search the database and return a hResult from the query_appdb() */
function searchForApplication($search_words)
{
+ /* This would yield too many results and stress MySQL */
+ if(strlen($search_words) < 4)
+ return null;
+
/* cleanup search words */
$search_words = cleanupSearchWords($search_words);
+ /* The search string may have gotten shorter; even empty */
+ if(strlen($search_words) < 4)
+ return null;
+
/* remove any search words less than 4 letters */
$split_words = array();
$split_search_words = split(" ", $search_words);
More information about the wine-cvs
mailing list