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

Commit

Permalink
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 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
4 changes: 3 additions & 1 deletion src/Debug.php
Original file line number Diff line number Diff line change
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
11 changes: 11 additions & 0 deletions test/DebugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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 d387acb

Please sign in to comment.