]> git.wh0rd.org Git - tt-rss.git/commitdiff
prevent crashes on filter regexp being too advanced for our database when testing...
authorAndrew Dolgov <fox@fakecake.org>
Tue, 23 Oct 2012 12:58:07 +0000 (16:58 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Tue, 23 Oct 2012 12:58:07 +0000 (16:58 +0400)
include/functions.php

index 2fb14097fa7a38d6933b716efd8f0cc2829a452d..5588cea8d6a3a379dc845b5b0397fc5abfec7035 100644 (file)
 
                                $override_order = "updated DESC";
 
-                               $filter_query_part = filter_to_sql($filter) . " AND";
+                               $filter_query_part = filter_to_sql($filter);
+
+                               // Try to check if SQL regexp implementation chokes on a valid regexp
+                               $result = db_query($link, "SELECT true FROM ttrss_entries
+                                       WHERE $filter_query_part LIMIT 1", false);
+
+                               $test = db_fetch_result($result, 0, "true");
+
+                               if (!$test) {
+                                       $filter_query_part = "false AND";
+                               } else {
+                                       $filter_query_part .= " AND";
+                               }
+
                        } else {
                                $filter_query_part = "";
                        }