Skip to content

Commit ba9143d

Browse files
committed
🔨 removed eval() from plates templating engine 🤗
Signed-off-by: otengkwame <[email protected]>
1 parent 473881f commit ba9143d

File tree

1 file changed

+4
-36
lines changed

1 file changed

+4
-36
lines changed

Core/core/View/Plates.php

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -582,48 +582,16 @@ protected function run(string $template, $data = null)
582582
if (is_array($data)) {
583583
extract($data);
584584
}
585-
586-
$oblevel = ob_get_level();
587585

588586
ob_start();
589587

590588
$template = $this->replaceBlacklisted($template);
591589

592-
if (ENVIRONMENT === 'development')
593-
{
594-
$trace = debug_backtrace();
595-
$args = $trace[0]['args'];
596-
$path = $args[1]['platesPath'] . $args[1]['cacheName'];
597-
598-
session('__view_path', $path);
599-
}
600-
601-
try {
602-
eval(' ?' . '>' . $template . '<'. '?'. 'php ');
603-
} catch (\Exception $exception) {
604-
605-
while (ob_get_level() > $oblevel) {
606-
ob_end_clean();
607-
}
608-
609-
include_once(COREPATH . 'core/Base_Exceptions.php');
610-
611-
$exception = new \Base_Exceptions;
612-
613-
return $exception->show_exception($exception);
614-
615-
} catch (\ParseError $parseError) {
616-
617-
while (ob_get_level() > $oblevel) {
618-
ob_end_clean();
619-
}
620-
621-
include_once(COREPATH . 'core/Base_Exceptions.php');
590+
$templateFile = $this->platesPath . md5((string) $this->viewPath) . PHPEXT;
591+
592+
file_put_contents($templateFile, $template);
622593

623-
$exception = new \Base_Exceptions;
624-
625-
return $exception->show_exception($parseError);
626-
}
594+
include $templateFile;
627595

628596
$content = ob_get_clean();
629597

0 commit comments

Comments
 (0)