Fix a DOS on too large quick searches (too many tokens ==> very large SQL
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 11 Sep 2007 08:20:55 +0000 (10:20 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 11 Sep 2007 08:20:55 +0000 (10:20 +0200)
query)

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
ChangeLog
modules/search/classes.inc.php

index 19003a9..39d752a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,6 +39,9 @@ Bug/Wish:
         - #708: Fix title (fix by Laurent Penou from Gadz.org)             -FRU
         - #710: Adding grade do not degrade the database                   -FRU
 
+    * Search:
+        - Fix DOS on too large quick searches                              -FRU
+
     * Xnet:
         - #694: Color of 'Promotion' groups                                -ALK
 
index edebc8c..c682e1e 100644 (file)
@@ -252,6 +252,11 @@ class QuickSearch extends SField
 
         $s = preg_replace('!\d+!', ' ', $s);
         $this->strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY);
+        if (count($this->strings) > 5) {
+            global $page;
+            $page->trig("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
+            $this->strings = array_slice($this->strings, 0, 5);
+        }
 
         $s = preg_replace('! *- *!', '-', $r);
         $s = preg_replace('!([<>]) *!', ' \1', $s);