Skip to content

[11.x] Fix EncodedHtmlString to ignore instance of HtmlString #55543

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

Merged
merged 8 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion src/Illuminate/Mail/resources/views/html/footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<table class="footer" align="center" width="570" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td class="content-cell" align="center">
{{ Illuminate\Mail\Markdown::parse($slot) }}
{!! Illuminate\Mail\Markdown::parse($slot) !!}
</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Mail/resources/views/html/subcopy.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<table class="subcopy" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td>
{{ Illuminate\Mail\Markdown::parse($slot) }}
{!! Illuminate\Mail\Markdown::parse($slot) !!}
</td>
</tr>
</table>
2 changes: 1 addition & 1 deletion src/Illuminate/Mail/resources/views/html/table.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="table">
{{ Illuminate\Mail\Markdown::parse($slot) }}
{!! Illuminate\Mail\Markdown::parse($slot) !!}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<x-mail::message subcopy="This is a subcopy">

<x-mail::table>
*Hi* {{ $user->name }}

| Laravel | Table | Example |
| ------------- | :-----------: | ------------: |
| Col 2 is | Centered | $10 |
| Col 3 is | Right-Aligned | $20 |
</x-mail::table>

</x-mail::message>
50 changes: 50 additions & 0 deletions tests/Integration/Mail/MailableWithSecuredEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,56 @@ public function build()
$mailable->assertSeeInHtml($expected, false);
}

#[WithMigration]
#[DataProvider('markdownEncodedTemplateDataProvider')]
public function testItCanAssertMarkdownEncodedStringUsingTemplateWithTable($given, $expected)
{
$user = UserFactory::new()->create([
'name' => $given,
]);

$mailable = new class($user) extends Mailable
{
public $theme = 'taylor';

public function __construct(public User $user)
{
//
}

public function build()
{
return $this->markdown('message-table-with-template');
}
};

$mailable->assertSeeInHtml($expected, false);
$mailable->assertSeeInHtml('<p>This is a subcopy</p>', false);
$mailable->assertSeeInHtml(<<<'TABLE'
<table>
<thead>
<tr>
<th>Laravel</th>
<th align="center">Table</th>
<th align="right">Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>Col 2 is</td>
<td align="center">Centered</td>
<td align="right">$10</td>
</tr>
<tr>
<td>Col 3 is</td>
<td align="center">Right-Aligned</td>
<td align="right">$20</td>
</tr>
</tbody>
</table>
TABLE, false);
}

public static function markdownEncodedTemplateDataProvider()
{
yield ['[Laravel](https://laravel.com)', '<em>Hi</em> [Laravel](https://laravel.com)'];
Expand Down
50 changes: 50 additions & 0 deletions tests/Integration/Mail/MailableWithoutSecuredEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,56 @@ public function build()
$mailable->assertSeeInHtml($expected, false);
}

#[WithMigration]
#[DataProvider('markdownEncodedTemplateDataProvider')]
public function testItCanAssertMarkdownEncodedStringUsingTemplateWithTable($given, $expected)
{
$user = UserFactory::new()->create([
'name' => $given,
]);

$mailable = new class($user) extends Mailable
{
public $theme = 'taylor';

public function __construct(public User $user)
{
//
}

public function build()
{
return $this->markdown('message-table-with-template');
}
};

$mailable->assertSeeInHtml($expected, false);
$mailable->assertSeeInHtml('<p>This is a subcopy</p>', false);
$mailable->assertSeeInHtml(<<<'TABLE'
<table>
<thead>
<tr>
<th>Laravel</th>
<th align="center">Table</th>
<th align="right">Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>Col 2 is</td>
<td align="center">Centered</td>
<td align="right">$10</td>
</tr>
<tr>
<td>Col 3 is</td>
<td align="center">Right-Aligned</td>
<td align="right">$20</td>
</tr>
</tbody>
</table>
TABLE, false);
}

public static function markdownEncodedTemplateDataProvider()
{
yield ['[Laravel](https://laravel.com)', '<p><em>Hi</em> <a href="https://laravel.com">Laravel</a></p>'];
Expand Down