10000 feature #30024 [Debug] Display more details in the simple error page … · symfony/symfony@a6a1be8 · GitHub
[go: up one dir, main page]

Skip to content

Commit a6a1be8

Browse files
feature #30024 [Debug] Display more details in the simple error page of Debug (javiereguiluz)
This PR was squashed before being merged into the 4.3-dev branch (closes #30024). Discussion ---------- [Debug] Display more details in the simple error page of Debug | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29891 | License | MIT | Doc PR | - Note: this only changes the simple error page of Debug component, which is different from the full-featured error page of WebProfilerBundle. ----- #29891 shows a confusing error page. In #29928 we improved the first error message displayed to the user. In this PR we implement @nicolas-grekas' idea to replace the generic error page title by a better error message. So, this PR + #29928 would fix #29891 to me. ### Before ![error-before](https://user-images.githubusercontent.com/73419/51920135-1519b500-23e5-11e9-99d6-e9b631b97499.png) ### After ![error-after](https://user-images.githubusercontent.com/73419/51920141-1945d280-23e5-11e9-97c3-49b2170dbd15.png) Commits ------- 75ff151 [Debug] Display more details in the simple error page of Debug
2 parents e8c3f9e + 75ff151 commit a6a1be8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public function getContent(FlattenException $exception)
207207
$title = 'Sorry, the page you are looking for could not be found.';
208208
break;
209209
default:
210-
$title = 'Whoops, looks like something went wrong.';
210+
$title = $this->debug ? $this->escapeHtml($exception->getMessage()) : 'Whoops, looks like something went wrong.';
211211
}
212212

213213
if (!$this->debug) {

src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,17 @@ public function testDebug()
4848
$handler->sendPhpResponse(new \RuntimeException('Foo'));
4949
$response = ob_get_clean();
5050

51-
$this->assertContains('Whoops, looks like something went wrong.', $response);
51+
$this->assertContains('<h1 class="break-long-words exception-message">Foo</h1>', $response);
5252
$this->assertContains('<div class="trace trace-as-html">', $response);
53+
54+
// taken from https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
55+
$htmlWithXss = '<body onload=alert(\'test1\')> <b onmouseover=alert(\'Wufff!\')>click me!</b> <img src="j&#X41vascript:alert(\'test2\')"> <meta http-equiv="refresh"
56+
content="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgndGVzdDMnKTwvc2NyaXB0Pg">';
57+
ob_start();
58+
$handler->sendPhpResponse(new \RuntimeException($htmlWithXss));
59+
$response = ob_get_clean();
60+
61+
$this->assertContains(sprintf('<h1 class="break-long-words exception-message">%s</h1>', htmlspecialchars($htmlWithXss, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8')), $response);
5362
}
5463

5564
public function testStatusCode()

0 commit comments

Comments
 (0)
0