Fix Blaze Debug Bar Injection for Multi-Line Body Tags#133
Merged
ganyicz merged 2 commits intolivewire:mainfrom Mar 12, 2026
Merged
Fix Blaze Debug Bar Injection for Multi-Line Body Tags#133ganyicz merged 2 commits intolivewire:mainfrom
ganyicz merged 2 commits intolivewire:mainfrom
Conversation
Contributor
Benchmark Results
Median of 10 attempts, 5000 iterations x 10 rounds, 46.39s total |
Collaborator
|
Updated to implementation from Laravel Debugbar which adds the widget before closing |
Collaborator
|
Thanks! |
Contributor
Author
|
There's an error with your implementation though: i tried this below to fix if, but i noticed blaze profiler was injected into json responses as well, we might need to review your implementation. use Illuminate\Http\JsonResponse;
public function handle(Request $request, Closure $next): JsonResponse|Response
{
// ...
protected function injectDebugger(JsonResponse|Response $response, Debugger $debugger): void
{
// ... |
Collaborator
|
@faraweilyas pull in dev-main |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Blaze debug bar was injecting its HTML content inside Alpine.js
x-dataattributes instead of after the<body>tag, causing malformed HTML and broken JavaScript objects.Root Cause: The regex
/<body[^>]*>/iinDebuggerMiddleware.phponly matches single-line body tags. our admin layout uses multi-line body tags with complex Alpine.js attributes:This caused the debug bar to inject inside the
x-dataattribute value, breaking the JavaScript object syntax.Solution
Updated regex to handle multi-line body tags with quoted attributes:
'/<body(?:[^>"\']*|"[^"]*"|\'[^\'"]*\')*>/si'Impact