Report admin, fixed filter editor issues when strings with spaces were configured

This commit is contained in:
Andre Lorbach 2011-09-21 16:10:10 +02:00
parent 5dea27098a
commit 895f0fe321
4 changed files with 18 additions and 9 deletions

View File

@ -19,6 +19,8 @@ Version 3.2.2 (stable), ????-??-??
use Quotes to mark the start and end of a phrase, for example:
"Search for this" // Searches for full phrase
-"Search for this" // Excludes full phrase
- Report admin, fixed filter editor issues when full phrase strings
(with spaces) were configured.
---------------------------------------------------------------------------
Version 3.2.1 (stable), 2011-04-12
- Fixed timezone parsing in GetEventTime function. This caused problems

View File

@ -338,6 +338,7 @@ if ( isset($_GET['op']) )
$content['customTitle'] = $myReport['DisplayName'];
$content['customComment'] = "";
$content['filterString'] = "";
$content['filterString_htmlform'] = "";
// Init Custom Filters
InitCustomFilterDefinitions($myReport, "");
@ -427,6 +428,7 @@ if ( isset($_GET['op']) )
$content['customTitle'] = $mySavedReport['customTitle'];
$content['customComment'] = $mySavedReport['customComment'];
$content['filterString'] = $mySavedReport['filterString'];
$content['filterString_htmlform'] = htmlspecialchars($content['filterString']);
// Init Custom Filters
InitCustomFilterDefinitions($myReport, $mySavedReport['customFilters']);
@ -595,6 +597,7 @@ if ( isset($content['ISADDSAVEDREPORT']) && $content['ISADDSAVEDREPORT'] )
{
// Overwrite filterString from form data instead of filter array!
$content['filterString'] = DB_RemoveBadChars($_POST['report_filterString']);
$content['filterString_htmlform'] = htmlspecialchars($content['filterString']);
}
else
{
@ -603,7 +606,7 @@ if ( isset($content['ISADDSAVEDREPORT']) && $content['ISADDSAVEDREPORT'] )
{
// Get Filter array
$AllFilters = $_POST['Filters'];
// Loop through filters and build filterstring!
$i = 0;
foreach( $AllFilters as $tmpFilterID )
@ -716,9 +719,12 @@ if ( isset($content['ISADDSAVEDREPORT']) && $content['ISADDSAVEDREPORT'] )
}
// Append field value
$szFilterString .= $tmpFilterValue;
if ( strpos($tmpFilterValue, " ") === false || (substr($tmpFilterValue, 0, 1) == "\"" && substr($tmpFilterValue, strlen($tmpFilterValue)-1, 1) == "\"" ) )
$szFilterString .= $tmpFilterValue;
else
// Spaces are in search value, so we add quotes to the string!
$szFilterString .= "\"" . $tmpFilterValue . "\"";
}
// Append trailing space
$szFilterString .= " ";
}
@ -728,9 +734,10 @@ if ( isset($content['ISADDSAVEDREPORT']) && $content['ISADDSAVEDREPORT'] )
$i++;
}
// echo $content['filterString'] . "<br>";
// echo $szFilterString . "<br>";
// print_r ( $AllFilters );
// DEBUG stuff
// echo $content['filterString'] . "<br>\r\n";
// echo $szFilterString . "<br>\r\n";
// print_r ( $AllFilters );
}
}

View File

@ -563,7 +563,6 @@ abstract class LogStream {
return $myField['FieldID'];
}
return FALSE;
}
@ -603,6 +602,7 @@ abstract class LogStream {
// Use RegEx for intelligent splitting
$szFilterRgx = '/[,\s]++(?=(?:(?:[^"]*+"){2})*+[^"]*+$)(?=(?:(?:[^\']*+\'){2})*+[^\']*+$)(?=(?:[^()]*+\([^()]*+\))*+[^()]*+$)/x';
$tmpEntries = preg_split($szFilterRgx, $szFilters, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
//DEBUG print_r ( $tmpEntries );
foreach($tmpEntries as $myEntry)
{
// Continue if empty filter!
@ -1054,7 +1054,7 @@ abstract class LogStream {
$myEntry = str_replace("\\:", ":", $myEntry);
// Check for Begin and Ending Quotes and remove them from the search value!
$myEntry = preg_replace('/\\\\\\"/i', "$1", $myEntry);
$myEntry = preg_replace('/\\"/i', "$1", $myEntry);
// Assign value to filter array
$this->_filters[SYSLOG_MESSAGE][$iNum][FILTER_VALUE] = $myEntry;

View File

@ -288,7 +288,7 @@
</tr>
<tr>
<td align="left" class="cellmenu2_naked" width="150" valign="top" nowrap><b>{LN_REPORTS_FILTERSTRING}</b></td>
<td align="left" class="line1" width="100%"><font class="ErrorMsg">{LN_REPORTS_FILTERSTRING_ONLYEDITIF}</font></br><input type="text" name="report_filterString" size="100" maxlength="1024" value="{filterString}"></td>
<td align="left" class="line1" width="100%"><font class="ErrorMsg">{LN_REPORTS_FILTERSTRING_ONLYEDITIF}</font></br><input type="text" name="report_filterString" size="100" maxlength="1024" value="{filterString_htmlform}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2_naked" width="150" valign="top" nowrap><b>{LN_REPORTS_FILTEREDITOR}</b></td>