Skip to content

Commit

Permalink
Merge 9395e43 into 038fd57
Browse files Browse the repository at this point in the history
  • Loading branch information
akrabat committed May 1, 2024
2 parents 038fd57 + 9395e43 commit 862c1ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Slim/Error/Renderers/PlainTextErrorRenderer.php
Expand Up @@ -46,7 +46,7 @@ private function formatExceptionFragment(Throwable $exception): string
/** @var int|string $code */
$text .= sprintf("Code: %s\n", $code);

$text .= sprintf("Message: %s\n", htmlentities($exception->getMessage()));
$text .= sprintf("Message: %s\n", $exception->getMessage());

$text .= sprintf("File: %s\n", $exception->getFile());

Expand Down
7 changes: 6 additions & 1 deletion tests/Error/AbstractErrorRendererTest.php
Expand Up @@ -202,19 +202,24 @@ public function testXMLErrorRendererRenderHttpException()

public function testPlainTextErrorRendererFormatFragmentMethod()
{
$exception = new Exception('Oops..', 500);
$message = 'Oops.. <br>';
$exception = new Exception($message, 500);
$renderer = new PlainTextErrorRenderer();
$reflectionRenderer = new ReflectionClass(PlainTextErrorRenderer::class);

$method = $reflectionRenderer->getMethod('formatExceptionFragment');
$method->setAccessible(true);
$output = $method->invoke($renderer, $exception);
$this->assertIsString($output);

$this->assertMatchesRegularExpression('/.*Type:*/', $output);
$this->assertMatchesRegularExpression('/.*Code:*/', $output);
$this->assertMatchesRegularExpression('/.*Message*/', $output);
$this->assertMatchesRegularExpression('/.*File*/', $output);
$this->assertMatchesRegularExpression('/.*Line*/', $output);

// ensure the renderer doesn't reformat the message
$this->assertMatchesRegularExpression("/.*$message/", $output);
}

public function testPlainTextErrorRendererDisplaysErrorDetails()
Expand Down

0 comments on commit 862c1ed

Please sign in to comment.