Skip to content
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

Disable escaping for attribute merging #15159

Merged
merged 5 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraModalWindowAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraModalWindowAttributes as $extraModalWindowAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraModalWindowAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraModalWindowAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
data-field-wrapper
{{
$attributes
->merge($field?->getExtraFieldWrapperAttributes() ?? [])
->merge($field?->getExtraFieldWrapperAttributes() ?? [], escape: false)
->class(['fi-fo-field-wrp'])
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraFieldWrapperAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraFieldWrapperAttributes as $extraFieldWrapperAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraFieldWrapperAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraFieldWrapperAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraInputAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraInputAttributes as $extraInputAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraInputAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraInputAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/src/Components/DateTimePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function getExtraTriggerAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraTriggerAttributes as $extraTriggerAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraTriggerAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraTriggerAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
3 changes: 2 additions & 1 deletion packages/forms/src/Components/Repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Filament\Actions\Action;
use Filament\Forms\Contracts\HasForms;
use Filament\Schemas\Components\Concerns\CanBeCollapsed;
use Filament\Schemas\Components\Concerns\HasContainerGridLayout;
use Filament\Schemas\Components\Contracts\CanConcealComponents;
use Filament\Schemas\Components\Contracts\HasExtraItemActions;
use Filament\Schemas\Schema;
Expand All @@ -30,7 +31,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
use Concerns\CanGenerateUuids;
use Concerns\CanLimitItemsLength;
use Concerns\HasExtraItemActions;
use \Filament\Schemas\Components\Concerns\HasContainerGridLayout;
use HasContainerGridLayout;
use HasReorderAnimationDuration;

protected string | Closure | null $addActionLabel = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div
{{
$attributes
->merge($entry?->getExtraEntryWrapperAttributes() ?? [])
->merge($entry?->getExtraEntryWrapperAttributes() ?? [], escape: false)
->class(['fi-in-entry-wrp'])
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraEntryWrapperAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraEntryWrapperAttributes as $extraEntryWrapperAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraEntryWrapperAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraEntryWrapperAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraSidebarAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraSidebarAttributes as $extraSidebarAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraSidebarAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraSidebarAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraTopbarAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraTopbarAttributes as $extraTopbarAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraTopbarAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraTopbarAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
2 changes: 1 addition & 1 deletion packages/support/src/Concerns/HasExtraAlpineAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraAlpineAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraAlpineAttributes as $extraAlpineAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAlpineAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAlpineAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
2 changes: 1 addition & 1 deletion packages/support/src/Concerns/HasExtraAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraAttributes as $extraAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
$wireModelAttribute => $wireModel,
'x-bind:id' => '$id(\'input\')',
'x-on:keyup' => 'if ($event.key === \'Enter\') { $wire.$refresh() }',
])
], escape: false)
"
/>
</x-filament::input.wrapper>
Expand Down
3 changes: 2 additions & 1 deletion packages/tables/src/Columns/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Filament\Support\Components\ViewComponent;
use Filament\Support\Concerns\CanAggregateRelatedModels;
use Filament\Support\Concerns\CanGrow;
use Filament\Support\Concerns\CanSpanColumns;
use Filament\Support\Concerns\HasAlignment;
use Filament\Support\Concerns\HasCellState;
use Filament\Support\Concerns\HasExtraAttributes;
Expand All @@ -25,6 +26,7 @@ class Column extends ViewComponent
{
use CanAggregateRelatedModels;
use CanGrow;
use CanSpanColumns;
use Concerns\BelongsToGroup;
use Concerns\BelongsToLayout;
use Concerns\BelongsToTable;
Expand All @@ -46,7 +48,6 @@ class Column extends ViewComponent
use Concerns\HasRowLoopObject;
use Concerns\HasWidth;
use Concerns\InteractsWithTableQuery;
use \Filament\Support\Concerns\CanSpanColumns;
use HasAlignment;
use HasCellState;
use HasExtraAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraCellAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraCellAttributes as $extraCellAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraCellAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraCellAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getExtraHeaderAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraHeaderAttributes as $extraHeaderAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraHeaderAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraHeaderAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down
4 changes: 2 additions & 2 deletions packages/tables/src/Columns/ImageColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function getExtraImgAttributes(): array
$temporaryAttributeBag = new ComponentAttributeBag;

foreach ($this->extraImgAttributes as $extraImgAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraImgAttributes));
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraImgAttributes), escape: false);
}

return $temporaryAttributeBag->getAttributes();
Expand Down Expand Up @@ -452,7 +452,7 @@ public function toEmbeddedHtml(): string
theme: $store.theme,
}'
: null,
])
], escape: false)
->style([
"height: {$height}" => $height,
"width: {$width}" => $width,
Expand Down
4 changes: 2 additions & 2 deletions packages/tables/src/Columns/TextColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public function toEmbeddedHtml(): string
ob_start(); ?>

<div <?= $attributes
->merge($stateItemAttributes->getAttributes())
->merge($stateItemAttributes->getAttributes(), escape: false)
->toHtml() ?>>
<?php if ($isBadge) { ?>
<span <?= $stateItemBadgeAttributes->toHtml() ?>>
Expand Down Expand Up @@ -422,7 +422,7 @@ public function toEmbeddedHtml(): string
'x-data' => ($stateOverListLimitCount && $isLimitedListExpandable)
? '{ isLimited: true }'
: null,
])
], escape: false)
->class([
'fi-ta-text-has-descriptions' => $hasDescriptions,
'fi-ta-text-list-limited' => $stateOverListLimitCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(new \Illuminate\View\ComponentAttributeBag)
->merge([
'wire:poll.' . $pollingInterval => $pollingInterval ? true : null,
])
], escape: false)
->class([
'fi-wi-stats-overview',
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use Filament\Resources\Resource;
use Filament\Tests\Fixtures\Models\PostCategory;
use Filament\Tests\Fixtures\Resources\PostCategories\Pages\CreatePostCategory;
use Filament\Tests\Fixtures\Resources\PostCategories\Pages\EditPostCategory;
use Filament\Tests\Fixtures\Resources\PostCategories\Pages\ListPostCategories;
use Filament\Tests\Fixtures\Resources\PostCategories\Pages\ViewPostCategory;

class PostCategoryResource extends Resource
{
Expand All @@ -16,10 +20,10 @@ class PostCategoryResource extends Resource
public static function getPages(): array
{
return [
'index' => \Filament\Tests\Fixtures\Resources\PostCategories\Pages\ListPostCategories::route('/'),
'create' => \Filament\Tests\Fixtures\Resources\PostCategories\Pages\CreatePostCategory::route('/create'),
'view' => \Filament\Tests\Fixtures\Resources\PostCategories\Pages\ViewPostCategory::route('/{record}'),
'edit' => \Filament\Tests\Fixtures\Resources\PostCategories\Pages\EditPostCategory::route('/{record}/edit'),
'index' => ListPostCategories::route('/'),
'create' => CreatePostCategory::route('/create'),
'view' => ViewPostCategory::route('/{record}'),
'edit' => EditPostCategory::route('/{record}/edit'),
];
}
}
12 changes: 8 additions & 4 deletions tests/src/Fixtures/Resources/Posts/PostResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Tests\Fixtures\Models\Post;
use Filament\Tests\Fixtures\Resources\Posts\Pages\CreatePost;
use Filament\Tests\Fixtures\Resources\Posts\Pages\EditPost;
use Filament\Tests\Fixtures\Resources\Posts\Pages\ListPosts;
use Filament\Tests\Fixtures\Resources\Posts\Pages\ViewPost;
use Illuminate\Database\Eloquent\Builder;

class PostResource extends Resource
Expand Down Expand Up @@ -70,10 +74,10 @@ public static function table(Table $table): Table
public static function getPages(): array
{
return [
'index' => \Filament\Tests\Fixtures\Resources\Posts\Pages\ListPosts::route('/'),
'create' => \Filament\Tests\Fixtures\Resources\Posts\Pages\CreatePost::route('/create'),
'view' => \Filament\Tests\Fixtures\Resources\Posts\Pages\ViewPost::route('/{record}'),
'edit' => \Filament\Tests\Fixtures\Resources\Posts\Pages\EditPost::route('/{record}/edit'),
'index' => ListPosts::route('/'),
'create' => CreatePost::route('/create'),
'view' => ViewPost::route('/{record}'),
'edit' => EditPost::route('/{record}/edit'),
];
}
}
12 changes: 8 additions & 4 deletions tests/src/Fixtures/Resources/Shop/Products/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use Filament\Resources\Resource;
use Filament\Tests\Fixtures\Models\Product;
use Filament\Tests\Fixtures\Resources\Shop\Products\Pages\CreateProduct;
use Filament\Tests\Fixtures\Resources\Shop\Products\Pages\EditProduct;
use Filament\Tests\Fixtures\Resources\Shop\Products\Pages\ListProducts;
use Filament\Tests\Fixtures\Resources\Shop\Products\Pages\ViewProduct;

class ProductResource extends Resource
{
Expand All @@ -16,10 +20,10 @@ class ProductResource extends Resource
public static function getPages(): array
{
return [
'index' => \Filament\Tests\Fixtures\Resources\Shop\Products\Pages\ListProducts::route('/'),
'create' => \Filament\Tests\Fixtures\Resources\Shop\Products\Pages\CreateProduct::route('/create'),
'view' => \Filament\Tests\Fixtures\Resources\Shop\Products\Pages\ViewProduct::route('/{record}'),
'edit' => \Filament\Tests\Fixtures\Resources\Shop\Products\Pages\EditProduct::route('/{record}/edit'),
'index' => ListProducts::route('/'),
'create' => CreateProduct::route('/create'),
'view' => ViewProduct::route('/{record}'),
'edit' => EditProduct::route('/{record}/edit'),
];
}
}
12 changes: 8 additions & 4 deletions tests/src/Fixtures/Resources/Users/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Tests\Fixtures\Models\User;
use Filament\Tests\Fixtures\Resources\Users\Pages\CreateUser;
use Filament\Tests\Fixtures\Resources\Users\Pages\EditUser;
use Filament\Tests\Fixtures\Resources\Users\Pages\ListUsers;
use Filament\Tests\Fixtures\Resources\Users\Pages\ViewUser;

class UserResource extends Resource
{
Expand Down Expand Up @@ -68,10 +72,10 @@ public static function table(Table $table): Table
public static function getPages(): array
{
return [
'index' => \Filament\Tests\Fixtures\Resources\Users\Pages\ListUsers::route('/'),
'create' => \Filament\Tests\Fixtures\Resources\Users\Pages\CreateUser::route('/create'),
'view' => \Filament\Tests\Fixtures\Resources\Users\Pages\ViewUser::route('/{record}'),
'edit' => \Filament\Tests\Fixtures\Resources\Users\Pages\EditUser::route('/{record}/edit'),
'index' => ListUsers::route('/'),
'create' => CreateUser::route('/create'),
'view' => ViewUser::route('/{record}'),
'edit' => EditUser::route('/{record}/edit'),
];
}
}