Skip to content

fix: escape the field name in the field row - #296

Merged
ManukMinasyan merged 1 commit into
3.xfrom
fix/escape-field-name-in-field-row
Nov 11, 2026
Merged

ManukMinasyan merged 1 commit into
3.xfrom
fix/escape-field-name-in-field-row

Conversation

@ManukMinasyan

Copy link
Copy Markdown
Member

The custom fields management page now shows a field's name as text. Before, the name went into the page as raw HTML in two places on each field row: the edit link label and its tooltip attribute. A name holding markup ran as script for anyone who opened the page with sections on, which is the package default.

What changed

resources/views/livewire/manage-custom-field.blade.php passes e($field->name) to both the HtmlString label and the x-tooltip.raw attribute.

Why this way

The label stays an HtmlString because it wraps the name in a truncate span. Escaping the name inside it keeps the markup and makes the name text.

The tooltip needs its own escape. Filament's link merges extra attributes with escape: false, and Laravel's attribute bag then only backslash-escapes quotes. A backslash does not end an HTML attribute, so "> broke out of it. Escaping only the label left this second sink open, and the test fails in that state. The browser decodes the entities before Alpine reads the attribute, and the tooltip has no .html modifier, so it shows the real name as text.

Behavior to know about

A name with &, < or quotes now displays as typed in both places. No migration, no config key.

Tests

tests/Feature/Admin/Pages/CustomFieldsFieldManagementTest.php: "renders the field name as text in the field row" renders a field named "><img src=x onerror=alert(1)> and asserts the raw tag is absent and both the label and the tooltip carry the escaped name.

Checked

At 927c573: the new test fails on 3.x as it stands, fails with only the label escaped, and passes with both. The test file passes (52 passed, 1 todo). Pint, rector and the arch tests pass.

Not checked

The tooltip in a real browser. The escaped attribute value is asserted, not rendered.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 15:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@ManukMinasyan
ManukMinasyan added this pull request to the merge queue Nov 11, 2026
Merged via the queue into 3.x with commit 6aaf609 Nov 11, 2026
7 checks passed
@ManukMinasyan
ManukMinasyan deleted the fix/escape-field-name-in-field-row branch November 11, 2026 15:55
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.

2 participants