-
Notifications
You must be signed in to change notification settings - Fork 11.4k
[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
[11.x] Fix EncodedHtmlString
to ignore instance of HtmlString
#55543
Conversation
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
avoid double encoding Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
@jbraband I made some changes to how we solve this. Also add some integration tests to cover this usage |
|
||
if ($value instanceof BackedEnum) { | ||
$value = $value->value; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy the logic from e()
function
framework/src/Illuminate/Support/helpers.php
Lines 127 to 142 in 18a2f33
function e($value, $doubleEncode = true) | |
{ | |
if ($value instanceof DeferringDisplayableValue) { | |
$value = $value->resolveDisplayableValue(); | |
} | |
if ($value instanceof Htmlable) { | |
return $value->toHtml(); | |
} | |
if ($value instanceof BackedEnum) { | |
$value = $value->value; | |
} | |
return htmlspecialchars($value ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', $doubleEncode); | |
} |
@crynobone I'm not at a computer at the moment, but one of the other templates in the mail folder had the parse method with the unescaped blade {!! !!} |
It's panel.blade.php @crynobone |
Was able to commit it from mobile |
I'll look to add a test for panel in the morning (CST) |
Signed-off-by: Mior Muhammad Zaki <[email protected]>
EncodedHtmlString
to ignore instance of HtmlString
Thanks @crynobone! 🎉 |
I do not see existing tests for the sub-mail components (header, footer, table, etc) and so are excluded from this PR. The related PR #55149 also do not contain tests for similar changes to button, header, layout, message, and panel.
After updating to Laravel 11.44.3 yesterday, the mail components started rendering escaped HTML. Note that some mail components were fixed by @crynobone in #55149.
Here is a sample markdown template that demonstrates the 3 mail components included in this PR, subcopy, table, and footer
The resulting rendered mailable.
Note: the closing
}
seen at the end of the sub-copy in the image has already been fixed by @crynobone in #55530 and is waiting for release next weekI am happy to makes changes or additions.