Skip to content

Commit

Permalink
Bluescreen: added length limit for exception message (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored and dg committed Sep 13, 2019
1 parent eb59baf commit d97208b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Tracy/BlueScreen/BlueScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
class BlueScreen
{
private const MAX_MESSAGE_LENGTH = 2000;

/** @var string[] */
public $info = [];

Expand Down Expand Up @@ -112,7 +114,7 @@ private function renderTemplate(\Throwable $exception, string $template, $toScre
$messageHtml = preg_replace(
'#\'\S(?:[^\']|\\\\\')*\S\'|"\S(?:[^"]|\\\\")*\S"#',
'<i>$0</i>',
htmlspecialchars((string) $exception->getMessage(), ENT_SUBSTITUTE, 'UTF-8')
htmlspecialchars(Dumper::encodeString((string) $exception->getMessage(), self::MAX_MESSAGE_LENGTH), ENT_SUBSTITUTE, 'UTF-8')
);
$info = array_filter($this->info);
$source = Helpers::getSource();
Expand Down
4 changes: 2 additions & 2 deletions src/Tracy/BlueScreen/assets/content.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';
<a id="tracy-bs-toggle" href="#" class="tracy-toggle"></a>
<div class="tracy-bs-main">
<div id="tracy-bs-error" class="panel">
<?php if ($exception->getMessage()): ?><p><?= Helpers::escapeHtml($title . $code) ?></p><?php endif ?>
<?php if ($exception->getMessage()): ?><p><?= Helpers::escapeHtml(Dumper::encodeString($title . $code, self::MAX_MESSAGE_LENGTH)) ?></p><?php endif ?>


<h1><span><?= $messageHtml ?: Helpers::escapeHtml($title . $code) ?></span>
<h1><span><?= $messageHtml ?: Helpers::escapeHtml(Dumper::encodeString($title . $code, self::MAX_MESSAGE_LENGTH)) ?></span>
<?php foreach ($actions as $item): ?>
<a href="<?= Helpers::escapeHtml($item['link']) ?>"<?= empty($item['external']) ? '' : ' target="_blank" rel="noreferrer noopener"'?>><?= Helpers::escapeHtml($item['label']) ?>&#x25ba;</a>
<?php endforeach ?></h1>
Expand Down

0 comments on commit d97208b

Please sign in to comment.