Skip to content

Commit 483ec55

Browse files
committed
Replace htmlentities with Debugger::esc
1 parent f9ef3a5 commit 483ec55

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/Views/exceptions/development.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @var Framework\Debug\ExceptionHandler $handler
55
*/
66

7+
use Framework\Debug\Debugger as D;
78
use Framework\Helpers\ArraySimple;
89

910
$lang = static function (string $line, array $args = []) use ($handler) : string {
@@ -19,7 +20,7 @@
1920
<meta name="robots" content="noindex">
2021
<meta name="viewport" content="width=device-width, initial-scale=1">
2122
<title><?= $lang('exception') ?>: <?=
22-
htmlentities($exception->getMessage()) ?></title>
23+
D::esc($exception->getMessage()) ?></title>
2324
<link rel="shortcut icon" href="data:image/png;base64,<?= base64_encode((string) file_get_contents(__DIR__ . '/favicons/development.png')) ?>">
2425
<style>
2526
<?= file_get_contents(__DIR__ . '/../assets/prism-aplus.css') ?>
@@ -253,7 +254,7 @@
253254
<small><?= $lang('exception') ?>:</small>
254255
<h1><?= $exception::class ?></h1>
255256
<small><?= $lang('message') ?>:</small>
256-
<h2><?= htmlentities($exception->getMessage()) ?></h2>
257+
<h2><?= D::esc($exception->getMessage()) ?></h2>
257258
<div class="search-section">
258259
<span><?= $lang('searchWith') ?>:</span>
259260
<?php
@@ -272,7 +273,7 @@
272273
<section class="file">
273274
<div>
274275
<small><?= $lang('file') ?>:</small>
275-
<h3><?= htmlentities($exception->getFile()) ?></h3>
276+
<h3><?= D::esc($exception->getFile()) ?></h3>
276277
</div>
277278
<div class="line">
278279
<small><?= $lang('line') ?>:</small>
@@ -338,7 +339,7 @@
338339
}
339340
}
340341
?></div>
341-
<pre class="code"><code class="language-php"><?= htmlentities($pre) ?></code></pre>
342+
<pre class="code"><code class="language-php"><?= D::esc($pre) ?></code></pre>
342343
</dd>
343344
</dl>
344345
<?php else : ?>
@@ -403,8 +404,8 @@
403404
}
404405
?>
405406
<tr>
406-
<th><?= htmlentities($field) ?></th>
407-
<td><?= htmlentities((string) $value) ?></td>
407+
<th><?= D::esc($field) ?></th>
408+
<td><?= D::esc((string) $value) ?></td>
408409
</tr>
409410
<?php
410411
endforeach
@@ -429,16 +430,16 @@
429430
</tr>
430431
<tr>
431432
<th><?= $lang('level') ?></th>
432-
<td><?= htmlentities($log->level->name) ?></td>
433+
<td><?= D::esc($log->level->name) ?></td>
433434
</tr>
434435
<tr>
435436
<th><?= $lang('id') ?></th>
436-
<td><?= htmlentities($log->id) ?></td>
437+
<td><?= D::esc($log->id) ?></td>
437438
</tr>
438439
<tr>
439440
<th><?= $lang('message') ?></th>
440441
<td dir="ltr">
441-
<pre><code class="language-log"><?= htmlentities($log->message) ?></code></pre>
442+
<pre><code class="language-log"><?= D::esc($log->message) ?></code></pre>
442443
</td>
443444
</tr>
444445
</table>

src/Views/exceptions/production.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/**
33
* @var Framework\Debug\ExceptionHandler $handler
44
*/
5+
use Framework\Debug\Debugger as D;
56

67
/**
78
* @param string $line
@@ -55,19 +56,19 @@
5556
<?php if ($log) : ?>
5657
<?php if ($isRtl) : ?>
5758
<p><span class="log-id"
58-
title="<?= htmlentities($lang('clickToCopyLogId')) ?>"
59-
><?= htmlentities($log->id) ?></span> :<?= $lang('logId') ?>
59+
title="<?= D::esc($lang('clickToCopyLogId')) ?>"
60+
><?= D::esc($log->id) ?></span> :<?= $lang('logId') ?>
6061
</p>
6162
<?php else : ?>
6263
<p><?= $lang('logId') ?>: <span class="log-id"
63-
title="<?= htmlentities($lang('clickToCopyLogId')) ?>"
64-
><?= htmlentities($log->id) ?></span>
64+
title="<?= D::esc($lang('clickToCopyLogId')) ?>"
65+
><?= D::esc($log->id) ?></span>
6566
</p>
6667
<?php endif ?>
6768
<script>
6869
document.querySelector('.log-id').onclick = function () {
6970
navigator.clipboard.writeText(this.innerText);
70-
alert("<?= htmlentities($lang('logIdCopied')) ?>");
71+
alert("<?= D::esc($lang('logIdCopied')) ?>");
7172
}
7273
</script>
7374
<?php endif ?>

0 commit comments

Comments
 (0)