-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[12.x] Render newlines in query tooltip #57310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
taylorotwell
merged 9 commits into
laravel:12.x
from
faisuc:fix/exceptions-renderer-tooltip-newlines-escape
Oct 16, 2025
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eb9da26
Escape multiline tooltip content in exceptions renderer (nl2br(e()))
faisuc 36ad3ed
Create RenderBladeFilesTest.php
faisuc b6657d3
Update RenderBladeFilesTest.php
faisuc c16a4e6
Refactor setUp method to defineEnvironment method
crynobone a2f862c
Update src/Illuminate/Foundation/resources/exceptions/renderer/compon…
crynobone d452895
rename test files
crynobone 81271e2
Render multiline query tooltips safely with nl2br(e(...))
faisuc 5144eb3
Format
avosalmon ae3835f
adjustments
faisuc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
tests/Foundation/Exceptions/Renderer/RenderBladeFilesTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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('<script>bad()</script>', $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); | ||
| } | ||
| } | ||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.