Skip to content

Commit

Permalink
Fix XSS in email viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
fuelen committed Aug 31, 2020
1 parent 4d20168 commit 8221dd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions lib/bamboo/plug/sent_email_viewer/index.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,22 @@
<a
class="email-summary <%= Bamboo.SentEmailViewerPlug.Helper.selected_email_class(email, @selected_email) %>"
href="<%= "#{@base_path}/#{Bamboo.SentEmail.get_id(email)}" %>">
<span class="email-summary-subject truncate"><%= email.subject %></span>
<span class="email-summary-subject truncate" title="<%= Plug.HTML.html_escape(email.subject) %>">
<%= Plug.HTML.html_escape(email.subject) %>
</span>
<span class="email-summary-recipients truncate">
<%= Bamboo.SentEmailViewerPlug.Helper.format_email_address(email.from) %>
to <%= Bamboo.SentEmailViewerPlug.Helper.email_addresses(email) %>
</span>
<span class="email-summary-body-excerpt"><%= email.text_body %></span>
<span class="email-summary-body-excerpt">
<%= Plug.HTML.html_escape(email.text_body) %>
</span>
</a>
<% end %>
</aside>
<section class="email-detail-pane">
<section class="email-detail-hero">
<span class="email-detail-subject"><%= @selected_email.subject %></span>
<span class="email-detail-subject"><%= Plug.HTML.html_escape(@selected_email.subject) %></span>
<span class="email-detail-recipients">
From <strong><%= Bamboo.SentEmailViewerPlug.Helper.format_email_address(@selected_email.from) %></strong>
to <strong><%= Bamboo.SentEmailViewerPlug.Helper.email_addresses(@selected_email) %></strong>
Expand All @@ -183,7 +187,7 @@
</p>

<h3 class="email-detail-body-label">Text Body</h3>
<pre class="email-detail-body"><%= @selected_email.text_body %></pre>
<pre class="email-detail-body"><%= Plug.HTML.html_escape(@selected_email.text_body) %></pre>
</section>
</section>
</main>
Expand Down
4 changes: 2 additions & 2 deletions lib/mix/start_sent_email_viewer_task.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Mix.Tasks.Bamboo.StartSentEmailViewer do
Bamboo.Email.new_email(
from: "me@gmail.com",
to: "someone@foo.com",
subject: "#{index} - This is a long subject for testing truncation",
subject: "#{index} - <em>This</em> is a long subject for testing truncation",
html_body: """
Check different tag <strong>styling</strong>
Expand All @@ -32,7 +32,7 @@ defmodule Mix.Tasks.Bamboo.StartSentEmailViewer do
long to see how it expands on to the next line
Sincerely,
Me
Me and <em>html tag</em>
"""
)
|> Bamboo.Mailer.normalize_addresses()
Expand Down

0 comments on commit 8221dd3

Please sign in to comment.