From 6f130a54d22debc4c9838aef2243c6ec6b12190b Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 10 Mar 2010 10:20:35 +0000 Subject: [PATCH] Added new checks to prevent broken filter configs git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16373 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_management.inc | 2 ++ gosa-core/include/class_userFilter.inc | 7 ++++++- gosa-core/include/class_userFilterEditor.inc | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gosa-core/include/class_management.inc b/gosa-core/include/class_management.inc index bd24cc5ec..681d8381b 100644 --- a/gosa-core/include/class_management.inc +++ b/gosa-core/include/class_management.inc @@ -182,6 +182,8 @@ class management if(userFilter::userFilteringAvailable()){ $dummy = ""; $this->registerAction("editFilter", "editFilter"); + + print_a(userFilter::getFilter()); } // Display list diff --git a/gosa-core/include/class_userFilter.inc b/gosa-core/include/class_userFilter.inc index bdb37df5d..5e34c36f1 100644 --- a/gosa-core/include/class_userFilter.inc +++ b/gosa-core/include/class_userFilter.inc @@ -203,7 +203,12 @@ class userFilter extends plugin for($i=0; $i < $attrs['gosaUserDefinedFilter']['count']; $i++){ $tmp = userFilter::explodeFilterString($attrs['gosaUserDefinedFilter'][$i]); if(!isset($tmp['name'])) continue; - + + // Remove line breaks from the filter, which may were added for better reading. + $c = preg_split('/\n/',$tmp['filter']); + foreach($c as $key => $str) $c[$key] = trim($str); + $tmp['filter'] = implode($c); + // The filter is visible if it is shared or if is one of our own creations. // ... and enabled. $visible = in_array('enable', $tmp['flags']) && diff --git a/gosa-core/include/class_userFilterEditor.inc b/gosa-core/include/class_userFilterEditor.inc index 5719106bb..ffff3e658 100644 --- a/gosa-core/include/class_userFilterEditor.inc +++ b/gosa-core/include/class_userFilterEditor.inc @@ -127,6 +127,14 @@ class userFilterEditor extends plugin $msgs[] = msgPool::invalid(_("Name"), $this->name,"/[a-z0-9\-_ ]/i"); } + // Count the number of opening and closing brackets - exclude escaped ones. + $f = preg_replace('/\\\\[\(\)]/',"",$this->filter); + $o = substr_count($f, '('); + $c = substr_count($f, ')'); + if($o != $c){ + $msgs[] = sprintf(_("Please check your filter, you have '%s' opening and '%s' closing brackets!"), $o, $c); + } + return($msgs); } -- 2.30.2