Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
}
},
"require": {
"php": ">=5.3.3",
"zendframework/zend-escaper": "self.version"
"php": ">=5.3.3"
},
"require-dev": {
"zendframework/zend-escaper": "2.*",
"zendframework/zend-escaper": "*",
"fabpot/php-cs-fixer": "1.7.*",
"satooshi/php-coveralls": "dev-master",
"phpunit/PHPUnit": "~4.0"
Expand Down
8 changes: 5 additions & 3 deletions src/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand Down Expand Up @@ -42,7 +42,7 @@ public static function getSapi()

/**
* Set the debug output environment.
* Setting a value of null causes Zend_Debug to use PHP_SAPI.
* Setting a value of null causes Zend\Debug\Debug to use PHP_SAPI.
*
* @param string $sapi
* @return void;
Expand Down Expand Up @@ -104,7 +104,9 @@ public static function dump($var, $label = null, $echo = true)
. PHP_EOL . $output
. PHP_EOL;
} else {
if (!extension_loaded('xdebug')) {
if (null !== static::$escaper) {
$output = static::$escaper->escapeHtml($output);
} elseif (!extension_loaded('xdebug')) {
$output = static::getEscaper()->escapeHtml($output);
}

Expand Down
13 changes: 12 additions & 1 deletion test/DebugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest;

use Zend\Debug\Debug;
use Zend\Escaper\Escaper;

/**
* @group Zend_Debug
Expand Down Expand Up @@ -94,4 +95,14 @@ public function testXdebugEnabledAndNonCliSapiDoesNotEscapeSpecialChars()
$this->assertContains("</pre>", $result);
}

public function testDebugHaveEscaper()
{
$escaper = new Escaper;
Debug::setEscaper($escaper);

$a = array("a" => "<script type=\"text/javascript\"");
$result = Debug::dump($a, "LABEL", false);
$this->assertContains("&lt;script type=&quot;text/javascript&quot;&quot;", $result);
}

}

0 comments on commit 717bd59

Please sign in to comment.