Skip to content

Commit

Permalink
fixed XSS in the exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 10, 2015
1 parent 43f74ef commit 1af6a9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Symfony/Component/Debug/ExceptionHandler.php
Expand Up @@ -131,14 +131,15 @@ public function getContent(FlattenException $exception)
}

$content = '';
$flags = PHP_VERSION_ID >= 50400 ? ENT_QUOTES | ENT_SUBSTITUTE : ENT_QUOTES;
if ($this->debug) {
try {
$count = count($exception->getAllPrevious());
$total = $count + 1;
foreach ($exception->toArray() as $position => $e) {
$ind = $count - $position + 1;
$class = $this->abbrClass($e['class']);
$message = nl2br($e['message']);
$message = nl2br(htmlspecialchars($e['message'], $flags, $this->charset));
$content .= sprintf(<<<EOF
<div class="block_exception clear_fix">
<h2><span>%d/%d</span> %s: %s</h2>
Expand Down Expand Up @@ -169,7 +170,7 @@ public function getContent(FlattenException $exception)
} catch (\Exception $e) {
// something nasty happened and we cannot throw an exception anymore
if ($this->debug) {
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), htmlspecialchars($e->getMessage(), $flags, $this->charset));
} else {
$title = 'Whoops, looks like something went wrong.';
}
Expand Down

0 comments on commit 1af6a9e

Please sign in to comment.