From 078905ed9507808b260d34fd8928e79e3a600d1d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 8 May 2012 14:24:57 +0200 Subject: [PATCH] fixed dump function is_safe value when html_errors is not defined in php.ini (closes #720) --- lib/Twig/Extension/Debug.php | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/lib/Twig/Extension/Debug.php b/lib/Twig/Extension/Debug.php index aab7093..8059df0 100644 --- a/lib/Twig/Extension/Debug.php +++ b/lib/Twig/Extension/Debug.php @@ -18,7 +18,13 @@ class Twig_Extension_Debug extends Twig_Extension public function getFunctions() { // dump is safe if var_dump is overriden by xdebug - $isDumpOutputHtmlSafe = extension_loaded('xdebug') && (false === get_cfg_var('xdebug.overload_var_dump') || get_cfg_var('xdebug.overload_var_dump')) && get_cfg_var('html_errors'); + $isDumpOutputHtmlSafe = extension_loaded('xdebug') + // false means that it was not set (and the default is on) or it explicitly enabled + && (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump')) + // false means that it was not set (and the default is on) or it explicitly enabled + // xdebug.overload_var_dump produces HTML only when html_errors is also enabled + && (false === ini_get('html_errors') || ini_get('html_errors')) + ; return array( 'dump' => new Twig_Function_Function('twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)), -- 1.7.2.5