Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a42dbe3

Browse files
committed
bug #44714 [WebProfilerBundle] fix Email HTML preview (94noni)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [WebProfilerBundle] fix Email HTML preview | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #44696 Fix #44703 | License | MIT ## First issue: When swapping the order of `base64` & `charset=utf-8` it works well Friendly ping @lyrixx as PR author ## Second issue: Friendly ping @Art4 as issue author As the `Mime\Email` is: ```php /** * @return resource|string|null */ public function getHtmlBody() { return $this->html; } ``` Commits ------- fe1aee8 [WebProfilerBundle] fix Email HTML preview
2 parents bfbc5a6 + fe1aee8 commit a42dbe3

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -141,42 +141,48 @@
141141
</div>
142142
{% if message.htmlBody is defined %}
143143
{# Email instance #}
144-
<div class="tab">
145-
<h3 class="tab-title">HTML preview</h3>
146-
<div class="tab-content">
147-
<pre class="prewrap" style="max-height: 600px">
148-
<iframe
149-
src="data:text/html;base64;charset=utf-8,{{ collector.base64Encode(message.htmlBody()) }}"
150-
style="height: 80vh;width: 100%;"
151-
>
152-
</iframe>
153-
</pre>
144+
{% set htmlBody = message.htmlBody() %}
145+
{% if htmlBody is not null %}
146+
<div class="tab">
147+
<h3 class="tab-title">HTML Preview</h3>
148+
<div class="tab-content">
149+
<pre class="prewrap" style="max-height: 600px">
150+
<iframe
151+
src="data:text/html;charset=utf-8;base64,{{ collector.base64Encode(htmlBody) }}"
152+
style="height: 80vh;width: 100%;"
153+
>
154+
</iframe>
155+
</pre>
156+
</div>
154157
</div>
155-
</div>
156-
<div class="tab">
157-
<h3 class="tab-title">HTML Content</h3>
158-
<div class="tab-content">
159-
<pre class="prewrap" style="max-height: 600px">
160-
{%- if message.htmlCharset() %}
161-
{{- message.htmlBody()|convert_encoding('UTF-8', message.htmlCharset()) }}
162-
{%- else %}
163-
{{- message.htmlBody() }}
164-
{%- endif -%}
165-
</pre>
158+
<div class="tab">
159+
<h3 class="tab-title">HTML Content</h3>
160+
<div class="tab-content">
161+
<pre class="prewrap" style="max-height: 600px">
162+
{%- if message.htmlCharset() %}
163+
{{- htmlBody|convert_encoding('UTF-8', message.htmlCharset()) }}
164+
{%- else %}
165+
{{- htmlBody }}
166+
{%- endif -%}
167+
</pre>
168+
</div>
166169
</div>
167-
</div>
168-
<div class="tab">
169-
<h3 class="tab-title">Text Content</h3>
170-
<div class="tab-content">
171-
<pre class="prewrap" style="max-height: 600px">
172-
{%- if message.textCharset() %}
173-
{{- message.textBody()|convert_encoding('UTF-8', message.textCharset()) }}
174-
{%- else %}
175-
{{- message.textBody() }}
176-
{%- endif -%}
177-
</pre>
170+
{% endif %}
171+
{% set textBody = message.textBody() %}
172+
{% if textBody is not null %}
173+
<div class="tab">
174+
<h3 class="tab-title">Text Content</h3>
175+
<div class="tab-content">
176+
<pre class="prewrap" style="max-height: 600px">
177+
{%- if message.textCharset() %}
178+
{{- textBody|convert_encoding('UTF-8', message.textCharset()) }}
179+
{%- else %}
180+
{{- textBody }}
181+
{%- endif -%}
182+
</pre>
183+
</div>
178184
</div>
179-
</div>
185+
{% endif %}
180186
{% for attachment in message.attachments %}
181187
<div class="tab">
182188
<h3 class="tab-title">Attachment #{{ loop.index }}</h3>

0 commit comments

Comments
 (0)