From 2035f1d48f24ade399657cc04116492241553ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Sun, 16 Dec 2007 14:09:24 +0000 Subject: #194098 by mfer, theborg: reset theme in drupal_eval(), so the evaluated code will not see the caller module as current theme --- includes/common.inc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index fdf7dc2f0..c2b1d5914 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1499,10 +1499,29 @@ function drupal_map_assoc($array, $function = NULL) { * output of the code. */ function drupal_eval($code) { + global $theme_path, $theme_info, $conf; + + // Store current theme path. + $old_theme_path = $theme_path; + + // Restore theme_path to the theme, as long as drupal_eval() executes, + // so code evaluted will not see the caller module as the current theme. + // If theme info is not initialized get the path from theme_default. + if (!isset($theme_info)) { + $theme_path = drupal_get_path('theme', $conf['theme_default']); + } + else { + $theme_path = dirname($theme_info->filename); + } + ob_start(); print eval('?>'. $code); $output = ob_get_contents(); ob_end_clean(); + + // Recover original theme path. + $theme_path = $old_theme_path; + return $output; } -- cgit v1.2.3