Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
language="php"
truncate
class="text-xs min-w-0"
data-tippy-content="{{ $source }}"
data-tippy-content="{!! nl2br(e($source)) !!}"
/>
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class="border border-neutral-200 dark:border-none bg-white dark:bg-white/[3%] ro
language="sql"
truncate
class="min-w-0"
data-tippy-content="{{ $sql }}"
data-tippy-content="{!! nl2br(e($sql)) !!}"
/>
</div>
<div class="text-neutral-500 dark:text-neutral-200 text-right flex-shrink-0">{{ $time }}ms</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="uppercase text-neutral-500 dark:text-neutral-400 shrink-0">{{ $key }}</div>
<div class="min-w-6 grow h-3 border-b-2 border-dotted border-neutral-300 dark:border-white/20"></div>
<div class="truncate text-neutral-900 dark:text-white">
<span data-tippy-content="{{ $value }}">
<span data-tippy-content="{!! nl2br(e($value)) !!}">
{{ $value }}
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="uppercase text-neutral-500 dark:text-neutral-400 shrink-0">{{ $key }}</div>
<div class="min-w-6 grow h-3 border-b-2 border-dotted border-neutral-300 dark:border-white/20"></div>
<div class="truncate text-neutral-900 dark:text-white">
<span data-tippy-content="{{ $value }}">
<span data-tippy-content="{!! nl2br(e($value)) !!}">
{{ $value }}
</span>
</div>
Expand Down
77 changes: 77 additions & 0 deletions tests/Foundation/Exceptions/Renderer/RenderBladeFilesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Illuminate\Tests\Foundation\Exceptions\Renderer;

use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;

use function Orchestra\Testbench\after_resolving;
use function Orchestra\Testbench\package_path;

#[WithConfig('app.debug', true)]
class RenderBladeFilesTest extends TestCase
{
protected function defineEnvironment($app)
{
after_resolving($app, 'view.engine.resolver', function ($resolver) {
$resolver->resolve('blade')->getCompiler()->withoutComponentTags();
});
}

public function testFormattedSourceTooltipRendersMultilineSafely(): void
{
$frame = new class
{
public function class() { return null; }
public function previous() { return null; }
public function source() { return "Foo::bar(1)\nAnother line"; }
};

$path = package_path('src/Illuminate/Foundation/resources/exceptions/renderer/components/formatted-source.blade.php');

$html = (string) $this->app['view']->file($path, ['frame' => $frame])->render();

$this->assertStringContainsString('data-tippy-content="', $html);
$this->assertMatchesRegularExpression('/data-tippy-content=\"[^\"]*<br\s*\/?>(?:(?!\").)*\"/s', $html);
}

public function testQueryTooltipRendersMultilineSafely(): void
{
$sql = "SELECT * FROM tests\nWHERE id = 1";
$queries = [[ 'connectionName' => 'mysql', 'sql' => $sql, 'time' => 1.23 ]];

$path = package_path('src/Illuminate/Foundation/resources/exceptions/renderer/components/query.blade.php');

$html = (string) $this->app['view']->file($path, ['queries' => $queries])->render();

$this->assertStringContainsString('data-tippy-content="', $html);
$this->assertMatchesRegularExpression('/data-tippy-content=\"[^\"]*<br\s*\/?>(?:(?!\").)*\"/s', $html);
}

public function testRequestHeaderTooltipRendersMultilineSafely(): void
{
$headers = [ 'X-Test' => "A\nB<script>bad()</script>" ];

$path = package_path('src/Illuminate/Foundation/resources/exceptions/renderer/components/request-header.blade.php');

$html = (string) $this->app['view']->file($path, ['headers' => $headers])->render();

$this->assertStringContainsString('data-tippy-content="', $html);
$this->assertMatchesRegularExpression('/data-tippy-content=\"[^\"]*<br\s*\/?>(?:(?!\").)*\"/s', $html);
$this->assertStringContainsString('&lt;script&gt;bad()&lt;/script&gt;', $html);
}

public function testRoutingTooltipRendersMultilineSafely(): void
{
$routing = [ 'URI' => "users/1\nedit" ];

$path = package_path('src/Illuminate/Foundation/resources/exceptions/renderer/components/routing.blade.php');

$html = (string) $this->app['view']->file($path, ['routing' => $routing])->render();

$this->assertStringContainsString('data-tippy-content="', $html);
$this->assertMatchesRegularExpression('/data-tippy-content=\"[^\"]*<br\s*\/?>(?:(?!\").)*\"/s', $html);
}
}


Loading