Skip to content

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

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

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

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. This ports the 3.x fix (#296) to 4.x.

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 14401a9, run locally because the tests workflow only runs for 3.x: the new test fails on 4.x as it stands and passes with the fix. The test file passes (43 passed, 1 todo). Pint 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:51

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 merged commit 7e5fa74 into 4.x Nov 11, 2026
2 checks passed
@ManukMinasyan
ManukMinasyan deleted the fix/escape-field-name-in-field-row-4x branch November 11, 2026 15:52
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