From 755037122c1c6c65dccad33679736130d1795d96 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 25 Sep 2021 23:35:27 +0200 Subject: [PATCH] Fix unquoted expression (variable instead of string), speed up search --- inc/class.dc.translater.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inc/class.dc.translater.php b/inc/class.dc.translater.php index b0d4f3b..e2dd186 100644 --- a/inc/class.dc.translater.php +++ b/inc/class.dc.translater.php @@ -458,11 +458,15 @@ class dcTranslater $parts = explode($func . '(', $content); // remove fisrt element from array array_shift($parts); - // put back first parenthesis - $parts = array_map(function($v){ return '(' . $v;}, $parts); // walk through parts $p = 0; foreach($parts as $part) { + // should start with quote + if (!in_array(substr($part,0,1), ['"', "'"])) { + continue; + } + // put back first parenthesis + $part = '('.$part; // find pairs of parenthesis preg_match_all("/\((?:[^\)\(]+|(?R))*+\)/s", $part, $subparts); // find quoted strings (single or double)