-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[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
base: 12.x
Are you sure you want to change the base?
[12.x] Render newlines in query tooltip #57310
Conversation
src/Illuminate/Foundation/resources/exceptions/renderer/components/request-header.blade.php
Outdated
Show resolved
Hide resolved
…ents/request-header.blade.php
Fixed failling tests |
truncate | ||
class="text-xs min-w-0" | ||
data-tippy-content="{{ $source }}" | ||
data-tippy-content="{!! nl2br(e($source)) !!}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't imagine $source
contains newlines. The same goes for routing parameters and request headers.
truncate | ||
class="min-w-0" | ||
data-tippy-content="{{ $sql }}" | ||
data-tippy-content="{!! nl2br(e($sql)) !!}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blade automatically escapes the variable.
data-tippy-content="{!! nl2br(e($sql)) !!}" | |
data-tippy-content="{{ nl2br($sql) }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback!
For the query tooltip, the goal is to render actual line breaks inside the tooltip rather than escaped <br>
tags. Using {{ nl2br($sql) }}
would escape the <br>
and show them as text, while nl2br(e($sql))
inside {!! !!}
keeps it safe (escaped first) and still displays formatted newlines correctly.
Regarding the suggestion to switch to {{ nl2br($sql) }}
, that would break the newline rendering because Blade would re-escape the <br>
tags. I’m keeping nl2br(e($sql))
and outputting it as HTML so the SQL content is properly escaped before being rendered with <br>
s:
data-tippy-content="{!! nl2br(e($sql)) !!}"
If you prefer avoiding raw braces, I can alternatively wrap it in an HtmlString
so Blade won’t escape it again:
data-tippy-content="{{ new \Illuminate\Support\HtmlString(nl2br(e($sql))) }}"
I’ve updated the PR accordingly and kept this scoped only to queries, since other components like request headers or routing parameters are unlikely to contain newlines and don’t need the same handling.
Appreciate the clarification and review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@faisuc With {{ nl2br($sql) }}
, nl2br
converts line breaks to <br>
and then {{ }}
escapes special characters, but Tippy.js supports HTML content.
allowHTML: true, |
I tested this and confirmed that actual line breaks are rendered.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated
This fixes frontend breakage on the exception renderer by escaping tooltip content and converting newlines to
<br>
. It applies to queries, formatted source, request headers, and routing values, preventing layout overlap and syntax highlighter glitches when tooltip content contains newlines. Fixes #57246.No breaking changes. This affects only the debug exception renderer UI and does not change any APIs.