Skip to content

Commit d5939f6

Browse files
committed
#2318 - fix parse params of plugin
1 parent 4b9d151 commit d5939f6

1 file changed

Lines changed: 7 additions & 20 deletions

File tree

system/View/Parser.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -762,28 +762,15 @@ protected function parsePlugins(string $template)
762762
{
763763
$params = [];
764764

765-
// Split on "words", but keep quoted groups together, accounting for escaped quotes.
766-
// Note: requires double quotes, not single quotes.
767-
$parts = str_getcsv($match[1], ' ');
768-
769-
foreach ($parts as $part)
770-
{
771-
if (empty($part))
772-
{
773-
continue;
774-
}
775-
776-
if (strpos($part, '=') !== false)
777-
{
778-
list($a, $b) = explode('=', $part);
779-
$params[$a] = $b;
780-
}
781-
else
782-
{
783-
$params[] = $part;
765+
preg_match_all('/([\w-]+=\"[^"]+\")|([\w-]+=[^\"\s=]+)/', trim($match[1]), $matchesParams);
766+
foreach ($matchesParams[0] as $item) {
767+
$keyVal = explode('=', $item);
768+
if (count($keyVal) == 2) {
769+
$params[$keyVal[0]] = str_replace('"', '', $keyVal[1]);
770+
} else {
771+
$params[] = $item;
784772
}
785773
}
786-
unset($parts);
787774

788775
$template = $isPair ? str_replace($match[0], $callable($match[2], $params), $template) : str_replace($match[0], $callable($params), $template);
789776
}

0 commit comments

Comments
 (0)