Skip to content

Conversation

faisuc
Copy link

@faisuc faisuc commented Oct 8, 2025

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.

@taylorotwell taylorotwell requested a review from avosalmon October 8, 2025 20:53
@taylorotwell taylorotwell marked this pull request as draft October 8, 2025 20:53
@crynobone
Copy link
Member

Fixed failling tests

@avosalmon
Copy link
Contributor

This PR wouldn't fix #57246. The tooltip is not causing the issue, but text truncation is broken on syntax-highlighted queries. I opened a PR to fix text truncation. #57315

Having said that, I think it's still nice to render newlines in the tooltip.

truncate
class="text-xs min-w-0"
data-tippy-content="{{ $source }}"
data-tippy-content="{!! nl2br(e($source)) !!}"
Copy link
Contributor

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)) !!}"
Copy link
Contributor

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.

Suggested change
data-tippy-content="{!! nl2br(e($sql)) !!}"
data-tippy-content="{{ nl2br($sql) }}"

Copy link
Author

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!

Copy link
Contributor

@avosalmon avosalmon Oct 10, 2025

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.

I tested this and confirmed that actual line breaks are rendered.

CleanShot 2025-10-10 at 13 40 30

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR updated

@avosalmon avosalmon changed the title Fix/exceptions renderer tooltip newlines escape [12.x] Render newlines in query tooltip Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New lines in querys in exception page breaks frontend and built-in syntax on the page

3 participants