Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion library/Zend/Debug/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
9 changes: 6 additions & 3 deletions library/Zend/Debug/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
},
"target-dir": "Zend/Debug",
"require": {
"php": ">=5.3.3",
"zendframework/zend-escaper": "self.version"
"php": ">=5.3.3"
},
"require-dev": {
"zendframework/zend-escaper": "*"
},
"suggest": {
"ext/xdebug": "XDebug, for better backtrace output"
"ext/xdebug": "XDebug, for better backtrace output",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change this to ext-xdebug on commit, as that's the proper format for extensions.

"zendframework/zend-escaper": "To support escaped output"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be in a "require-dev" section, as it's necessary for tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weierophinney done, I've added to require-dev also.

},
"extra": {
"branch-alias": {
Expand Down
11 changes: 11 additions & 0 deletions tests/ZendTest/Debug/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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually get a test failure here -- the actual content is not escaped...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weierophinney this work on my machine and on travis too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weierophinney any suggestion for it ? thanks.

}

}