Skip to content

if diff contains <tag>, incorrectly rendering html in emails #10

Description

@sunghyuk

sorry for short english and ugly code.

if diff contains tag(ex, xml file changes), incorrectly rendering html in emails

diff --git a/app/helpers/diff_mailer_helper.rb b/app/helpers/diff_mailer_helper.rb
index 26d2891..92fa3e6 100644
--- a/app/helpers/diff_mailer_helper.rb
+++ b/app/helpers/diff_mailer_helper.rb
@@ -43,12 +43,12 @@ module DiffMailerHelper
             <th #{replace_css("line-num")}>#{line.nb_line_right}</th>]
         if line.line_left.empty?
           result += %Q[<td #{replace_css(line.type_diff_right)}">
-              <pre #{replace_css("line-code")}>#{Redmine::CodesetUtil.to_utf8_by_setting line.line_right}</pre>
+              <pre #{replace_css("line-code")}>#{Redmine::CodesetUtil.to_utf8_by_setting line.line_right.gsub(/</, '&lt;').gsub(/>/, '&gt;')}</pre>
             </td>]
         else
           result += %Q[
             <td #{replace_css(line.type_diff_left)}">
-              <pre #{replace_css("line-code")}>#{Redmine::CodesetUtil.to_utf8_by_setting line.line_left}</pre>
+              <pre #{replace_css("line-code")}>#{Redmine::CodesetUtil.to_utf8_by_setting line.line_left.gsub(/</, '&lt;').gsub(/>/, '&gt;')}</pre>
             </td>]
         end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions