Skip to content
Permalink
Browse files

Bluescreen: added length limit for exception message (#383)

  • Loading branch information...
janbarasek authored and dg committed Sep 13, 2019
1 parent 364de83 commit fc37cedcd2dbb4dac0cfca8aa12ad7249a12fc36
Showing with 5 additions and 3 deletions.
  1. +3 −1 src/Tracy/BlueScreen/BlueScreen.php
  2. +2 −2 src/Tracy/BlueScreen/assets/content.phtml
@@ -15,6 +15,8 @@
*/
class BlueScreen
{
private const MAX_MESSAGE_LENGTH = 2000;
/** @var string[] */
public $info = [];
@@ -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();
@@ -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>

0 comments on commit fc37ced

Please sign in to comment.
You can’t perform that action at this time.