From dd8c36af4be29c311cd3d6094b083371a4794368 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Oct 2012 16:58:07 +0400 Subject: [PATCH] prevent crashes on filter regexp being too advanced for our database when testing filters (refs #508) --- include/functions.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/functions.php b/include/functions.php index 2fb14097f..5588cea8d 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 = ""; }