fix Debug::getEscaper() never called at Debug::dump() when xdebug is loaded #5240

Closed
wants to merge 6 commits into
from

Projects

None yet

3 participants

@samsonasik

if we set Debug::setEscaper(new \Zend\Escaper\Escaper) before Debug::dump() and we have xdebug, the getEscaper() never called. added condition so getEscaper() will be called.

@Maks3w Maks3w commented on an outdated diff Oct 21, 2013
library/Zend/Debug/Debug.php
@@ -104,7 +104,7 @@ public static function dump($var, $label = null, $echo = true)
. PHP_EOL . $output
. PHP_EOL;
} else {
- if (!extension_loaded('xdebug')) {
+ if (!extension_loaded('xdebug') || null !== static::$escaper) {
@Maks3w
Maks3w Oct 21, 2013

This breaks the lazy load of getEscaper

@Maks3w Maks3w commented on an outdated diff Oct 21, 2013
tests/ZendTest/Debug/DebugTest.php
@@ -94,4 +94,14 @@ public function testXdebugEnabledAndNonCliSapiDoesNotEscapeSpecialChars()
$this->assertContains("</pre>", $result);
}
+ public function testDebugHaveEscaper()
+ {
+ $escaper = new \Zend\Escaper\Escaper;
@Maks3w
Maks3w Oct 21, 2013

Import Escaper as use statement

@samsonasik

@Maks3w done. please let me know if something I missed, thanks ;)

@samsonasik

@Maks3w I have updated this PR

@weierophinney weierophinney commented on an outdated diff Oct 23, 2013
library/Zend/Debug/composer.json
},
"suggest": {
- "ext/xdebug": "XDebug, for better backtrace output"
+ "ext/xdebug": "XDebug, for better backtrace output",
@weierophinney
weierophinney Oct 23, 2013

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

@weierophinney weierophinney commented on the diff Oct 23, 2013
library/Zend/Debug/composer.json
},
"suggest": {
- "ext/xdebug": "XDebug, for better backtrace output"
+ "ext/xdebug": "XDebug, for better backtrace output",
+ "zendframework/zend-escaper": "To support escaped output"
@weierophinney
weierophinney Oct 23, 2013

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

@samsonasik
samsonasik Oct 23, 2013

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

@weierophinney weierophinney commented on the diff Oct 23, 2013
tests/ZendTest/Debug/DebugTest.php
@@ -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);
@weierophinney
weierophinney Oct 23, 2013

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

@samsonasik
samsonasik Oct 23, 2013

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

@samsonasik
samsonasik Oct 23, 2013

@weierophinney any suggestion for it ? thanks.

@weierophinney weierophinney added a commit that closed this pull request Oct 23, 2013
@weierophinney weierophinney Merge branch 'hotfix/5240'
Close #5240
d86ebd6
@weierophinney weierophinney added a commit that referenced this pull request Oct 23, 2013
@weierophinney weierophinney Merge branch 'hotfix/5240' into develop
Forward port #5240
1a4de8d
@weierophinney weierophinney added a commit to zendframework/zend-debug that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge pull request zendframework/zendframework#5240 from samsonasik/f…
…ix/escapercall

fix Debug::getEscaper() never called at Debug::dump() when xdebug is loaded
0f24adc
@weierophinney weierophinney added a commit to zendframework/zend-debug that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/5240' d387acb
@weierophinney weierophinney added a commit to zendframework/zend-debug that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/5240' into develop dce2043
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment