Skip to content
Permalink
Browse files

Always use delimiter not present in search expression

This avoids need to figure out correct escaping in case delimiter is
present in the expression.

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information...
nijel committed Jun 20, 2016
1 parent 2f49508 commit 4bcc606225f15bac0b07780e74f667f6ac283da7
Showing with 14 additions and 1 deletion.
  1. +14 −1 libraries/controllers/table/TableSearchController.php
@@ -726,9 +726,22 @@ private function _getRegexReplaceRows(
$result = $this->dbi->fetchResult($sql_query, 0);
if (is_array($result)) {
/* Iterate over possible delimiters to get one */
$delimiters = array('/', '@', '#', '~', '!', '$', '%', '^', '&', '_');
$found = false;
for ($i = 0; $i < count($delimiters); $i++) {
if (strpos($find, $delimiters[$i]) === false) {
$found = true;
break;
}
}
if (! $found) {
return false;
}
$find = $delimiters[$i] . $find . $delimiters[$i];
foreach ($result as $index=>$row) {
$result[$index][1] = preg_replace(
"/" . $find . "/",
$find,
$replaceWith,
$row[0]
);

0 comments on commit 4bcc606

Please sign in to comment.
You can’t perform that action at this time.