Skip to content

Comments

[12.x] Ensure mailable HTML assertions properly escape quotes#58595

Merged
taylorotwell merged 5 commits intolaravel:12.xfrom
jackbayliss:12.x-mailable-changes
Feb 4, 2026
Merged

[12.x] Ensure mailable HTML assertions properly escape quotes#58595
taylorotwell merged 5 commits intolaravel:12.xfrom
jackbayliss:12.x-mailable-changes

Conversation

@jackbayliss
Copy link
Contributor

@jackbayliss jackbayliss commented Feb 2, 2026

Closes #58586

When using assertSeeInHtml() escape is true by default but, apostrophes and quotes are not being properly escaped, causing assertions to fail such as:

// Blade template: {{ "It's a wonderful day" }}
// Renders as: It's a wonderful day in HTML

$mailable->assertSeeInHtml("It's a wonderful day"); // Would fail...

The fix ensures that quotes are properly escaped to match Blade's HTML escaping.. withQuote was being set based on if the markdown property was set, where as I think it should be left as true.. (its true by default) - to match the escape default.

I've targeted 12.x as everything passes and this only alters the assertion behaviour I can't think of a scenario where you'd expect it to not escape quotes etc, can target 13.x if you prefer! but felt like an oversight perhaps.

Have added a test to prevent regression 🫡

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@jackbayliss jackbayliss marked this pull request as ready for review February 2, 2026 18:11
@jackbayliss jackbayliss changed the title [12.x] Fix mailable HTML assertions to properly escape quotes [12.x] Ensure mailable HTML assertions properly escape quotes Feb 2, 2026
@taylorotwell
Copy link
Member

Hmm, so why the previous code there in the first place? When was it added and why?

@jackbayliss
Copy link
Contributor Author

jackbayliss commented Feb 3, 2026

@taylorotwell

It was added as part of #54737 but the tests added in that PR still pass with this change.

This exact same issue was fixed 3 years ago here #42923, but I believe it was re introduced with the above.

Perhaps @crynobone can answer that better?

🫡

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
@crynobone
Copy link
Member

The previous PR focus on Markdown usage and missed out example from just base view.

@jackbayliss
Copy link
Contributor Author

Thanks @crynobone !

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
@taylorotwell taylorotwell merged commit e765909 into laravel:12.x Feb 4, 2026
70 checks passed
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.

Apostrophe in Mailable::assertSeeInHtml() not escaped

3 participants