Skip to content

Commit

Permalink
fix: escape error message in ErrorPresenter to prevent XSS vulnerabil…
Browse files Browse the repository at this point in the history
…ities
  • Loading branch information
edmondas committed Dec 2, 2023
1 parent c051086 commit c79f9ae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Application/Presenter/ErrorPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ private function sanitizeMessage(string $message): string

private function renderError(string $msg, ?string $name): void
{
$safeMsg = htmlspecialchars($msg, ENT_QUOTES, 'UTF-8');
$safeName = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
$errorContent = ($name !== null) ? "$msg (Record: $safeName)" : $msg;
$errorContent = ($name !== null) ? "$safeMsg (Record: $safeName)" : $safeMsg;

echo <<<HTML
<div class="alert alert-danger">
Expand Down

0 comments on commit c79f9ae

Please sign in to comment.