From: Andrew Dolgov Date: Tue, 23 Oct 2012 12:58:07 +0000 (+0400) Subject: prevent crashes on filter regexp being too advanced for our database when testing... X-Git-Tag: 1.6.1~71 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=dd8c36af4be29c311cd3d6094b083371a4794368;p=tt-rss.git prevent crashes on filter regexp being too advanced for our database when testing filters (refs #508) --- diff --git a/include/functions.php b/include/functions.php index 2fb14097..5588cea8 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2321,7 +2321,20 @@ $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 = ""; }